EnumExtTest.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using NUnit.Framework.Internal;
  2. using Quadarax.Foundation.Core.Value.Extensions;
  3. namespace qdr.fnd.core.test.Value
  4. {
  5. [TestFixture(Category = "Fnd.Core")]
  6. public class EnumExtTest : BaseTest
  7. {
  8. private enum TestEnum
  9. {
  10. One,
  11. Two,
  12. Three
  13. }
  14. private enum TestEnum2
  15. {
  16. One2,
  17. Two2,
  18. Three2
  19. }
  20. protected override void OnSetup()
  21. {
  22. }
  23. protected override void OnTearDown()
  24. {
  25. }
  26. [Test]
  27. public void InOK()
  28. {
  29. TestEnum value = TestEnum.Three;
  30. Assert.That(value.In(TestEnum.One), Is.False);
  31. Assert.That(value.In(TestEnum.One, TestEnum.Two), Is.False);
  32. Assert.That(value.In(TestEnum.One, TestEnum.Two, TestEnum.Three), Is.True);
  33. Assert.That(value.In(TestEnum.Three), Is.True);
  34. Assert.That(value.In("Three"), Is.False);
  35. Assert.That(value.In("TestEnum.Three"), Is.False);
  36. Assert.That(value.In("XX"), Is.False);
  37. }
  38. [Test]
  39. public void InFail()
  40. {
  41. TestEnum value = TestEnum.Three;
  42. // empty tenant code
  43. Assert.That(Assert.Throws<ArgumentNullException>(() =>
  44. value.In(null))?.ParamName,
  45. Is.EqualTo("values"));
  46. }
  47. }
  48. }