Example #1
0
 public void ReturnsEnumGivenMatchingValue()
 {
     Assert.Equal(TestEnum.One, TestEnum.FromValue(1));
 }
Example #2
0
 public void ThrowsGivenNonMatchingValue()
 {
     Assert.Throws <SmartEnumNotFoundException>(() => TestEnum.FromValue(-1));
 }
Example #3
0
        public void ReturnsDefaultEnumGivenNonMatchingValue()
        {
            var defaultEnum = TestEnum.One;

            Assert.Equal(defaultEnum, TestEnum.FromValue(-1, defaultEnum));
        }
        public void ShouldNotEqualNonMatchingNewEnumInstance()
        {
            var expected = TestEnum.One;

            Assert.NotEqual(expected, TestEnum.CreateFromConstructor("Two", 2));
        }
        public void ShouldEqualMatchingNewEnumInstance()
        {
            var expected = TestEnum.One;

            Assert.Equal(expected, TestEnum.CreateFromConstructor(expected.Name, expected.Value));
        }
Example #6
0
 public void ThrowsGivenNonMatchingString()
 {
     Assert.Throws <SmartEnumNotFoundException>(() => TestEnum.FromName("Doesn't Exist"));
 }
Example #7
0
 public void ThrowsGivenNull()
 {
     Assert.Throws <ArgumentNullException>(() => TestEnum.FromName(null));
 }
Example #8
0
 public void ThrowsGivenEmptyString()
 {
     Assert.Throws <ArgumentException>(() => TestEnum.FromName(String.Empty));
 }
Example #9
0
 public void ReturnsEnumGivenMatchingName()
 {
     Assert.Equal(TestEnum.One, TestEnum.FromName("One"));
 }
Example #10
0
        public void ReturnsEnumGivenExplicitPriorUse()
        {
            string expected = TestEnum.One.Name;

            Assert.Equal(expected, TestEnum.FromName(expected).Name);
        }