예제 #1
0
        public void GetEnumValueAttribute_NoAttribute()
        {
            // Act
            var actual = EnumAttributeHelper.GetEnumValueAttribute <SimpleAttribute>(TestEnum.Value1);

            // Assert
            actual.ShouldHaveSameValueAs(null);
        }
예제 #2
0
        public void GetPropertyValue_String()
        {
            // Act
            var actual = EnumAttributeHelper.GetPropertyValue <TestEnum, SimpleAttribute, string>(TestEnum.Value3, attribute => attribute.MyString);

            // Assert
            actual.ShouldHaveSameValueAs("d");
        }
예제 #3
0
        public void GetEnumFromPropertyValue_ValueGiven()
        {
            // Arrange
            var expected = TestEnum.Value2;

            // Act
            var actual = EnumAttributeHelper.GetEnumFromPropertyValue <TestEnum, SimpleAttribute, int>(3, o => o.MyInt);

            // Assert
            actual.ShouldHaveSameValueAs(expected);
        }
예제 #4
0
        public void GetEnumFromPropertyValue_NullValueGiven()
        {
            // Arrange
            var expected = TestEnum.Value3;

            // Act
            var actual = EnumAttributeHelper.GetEnumFromPropertyValue <TestEnum, SimpleAttribute, string>(null, o => o.MyString);

            // Assert
            actual.ShouldHaveSameValueAs(expected);
        }
예제 #5
0
        public void GetEnumValueAttribute()
        {
            // Arrange
            var expected = new SimpleAttribute {
                MyInt = 1, MyString = "a"
            };

            // Act
            var actual = EnumAttributeHelper.GetEnumValueAttribute <SimpleAttribute>(TestEnum.Value0);

            // Assert
            actual.ShouldHaveSameValueAs(expected);
        }
예제 #6
0
 public void GetEnumFromPropertyValue_NullPropertyExpression()
 {
     // Act
     EnumAttributeHelper.GetEnumFromPropertyValue <TestEnum, SimpleAttribute, int>(1, null);
 }
예제 #7
0
 public void GetEnumValueAttribute_NullValue()
 {
     // Act
     EnumAttributeHelper.GetEnumValueAttribute <SimpleAttribute>(null);
 }
예제 #8
0
 public void GetPropertyValue_String_NoAttributeDefined()
 {
     // Act
     EnumAttributeHelper.GetPropertyValue <TestEnum, SimpleAttribute, string>(TestEnum.Value1, attribute => attribute.MyString);
 }
예제 #9
0
 public void GetPropertyValue_String_NullPropertyExpression()
 {
     // Act
     EnumAttributeHelper.GetPropertyValue <TestEnum, SimpleAttribute, string>(TestEnum.Value3, null);
 }
예제 #10
0
 public void GetPropertyValue_String_NotAnEnum()
 {
     // Act
     EnumAttributeHelper.GetPropertyValue <SimpleStruct, SimpleAttribute, string>(new SimpleStruct(), null);
 }