public void GenericTypeGettingAttributesInheritTest() { var type = typeof(NormalWithAttrClassWrapper2); var val1 = TypeReflections.GetAttributes <ModelOneAttribute>(type); var val2 = TypeReflections.GetAttributes <ModelTwoAttribute>(type); var val3 = TypeReflections.GetAttributes <ModelThreeAttribute>(type); var val4 = TypeReflections.GetAttributes <ModelFourAttribute>(type); val1.ShouldBeEmpty(); val2.ShouldBeEmpty(); val3.ShouldBeEmpty(); val4.ShouldNotBeEmpty(); val4.Count().ShouldBe(1); val1 = TypeReflections.GetAttributes <ModelOneAttribute>(type, ReflectionOptions.Inherit); val2 = TypeReflections.GetAttributes <ModelTwoAttribute>(type, ReflectionOptions.Inherit); val3 = TypeReflections.GetAttributes <ModelThreeAttribute>(type, ReflectionOptions.Inherit); val4 = TypeReflections.GetAttributes <ModelFourAttribute>(type, ReflectionOptions.Inherit); val1.ShouldNotBeEmpty(); val2.ShouldBeEmpty(); val3.ShouldNotBeEmpty(); val4.ShouldNotBeEmpty(); val1.Count().ShouldBe(2); val3.Count().ShouldBe(1); val4.Count().ShouldBe(1); }
public void DirectTypeGettingAttributesInheritTest() { var type = typeof(NormalWithAttrClassWrapper2); var one = typeof(ModelOneAttribute); var two = typeof(ModelTwoAttribute); var three = typeof(ModelThreeAttribute); var four = typeof(ModelFourAttribute); var val1 = TypeReflections.GetAttributes(type, one); var val2 = TypeReflections.GetAttributes(type, two); var val3 = TypeReflections.GetAttributes(type, three); var val4 = TypeReflections.GetAttributes(type, four); val1.ShouldBeEmpty(); val2.ShouldBeEmpty(); val3.ShouldBeEmpty(); val4.ShouldNotBeEmpty(); val4.Count().ShouldBe(1); val1 = TypeReflections.GetAttributes(type, one, ReflectionOptions.Inherit); val2 = TypeReflections.GetAttributes(type, two, ReflectionOptions.Inherit); val3 = TypeReflections.GetAttributes(type, three, ReflectionOptions.Inherit); val4 = TypeReflections.GetAttributes(type, four, ReflectionOptions.Inherit); val1.ShouldNotBeEmpty(); val2.ShouldBeEmpty(); val3.ShouldNotBeEmpty(); val4.ShouldNotBeEmpty(); val1.Count().ShouldBe(2); val3.Count().ShouldBe(1); val4.Count().ShouldBe(1); }
public void AllAttributeGettingTest() { var val = TypeReflections.GetAttributes(typeof(NormalWithAttrClass)); val.ShouldNotBeNull(); val.ShouldNotBeEmpty(); val.Count().ShouldBe(3); }
public void AllAttributeGettingInheritTest() { var val1 = TypeReflections.GetAttributes(typeof(NormalWithAttrClassWrapper2)); var val2 = TypeReflections.GetAttributes(typeof(NormalWithAttrClassWrapper2), ReflectionOptions.Inherit); val1.ShouldNotBeNull(); val1.ShouldNotBeEmpty(); val1.Count().ShouldBe(1); val2.ShouldNotBeNull(); val2.ShouldNotBeEmpty(); val2.Count().ShouldBe(4); }
public void GenericTypeGettingAttributesTest() { var type = typeof(NormalWithAttrClass); var val1 = TypeReflections.GetAttributes <ModelOneAttribute>(type); var val2 = TypeReflections.GetAttributes <ModelTwoAttribute>(type); var val3 = TypeReflections.GetAttributes <ModelThreeAttribute>(type); val1.ShouldNotBeEmpty(); val2.ShouldBeEmpty(); val3.ShouldNotBeEmpty(); val1.Count().ShouldBe(2); val3.Count().ShouldBe(1); }
public void DirectTypeGettingAttributesTest() { var type = typeof(NormalWithAttrClass); var one = typeof(ModelOneAttribute); var two = typeof(ModelTwoAttribute); var three = typeof(ModelThreeAttribute); var val1 = TypeReflections.GetAttributes(type, one); var val2 = TypeReflections.GetAttributes(type, two); var val3 = TypeReflections.GetAttributes(type, three); val1.ShouldNotBeEmpty(); val2.ShouldBeEmpty(); val3.ShouldNotBeEmpty(); val1.Count().ShouldBe(2); val3.Count().ShouldBe(1); }