public void GetParameterName_returnsParameterName() { AttributeTestClass testClass = new AttributeTestClass(); string result = testClass.GetParameterName(x => x.Age); Assert.AreEqual("@age", result); }
public void GetColumnName_returnsColumnName() { AttributeTestClass testClass = new AttributeTestClass(); string result = testClass.GetColumnName(x => x.Age); Assert.AreEqual("AGE", result); }
public void TestAttributeAllowedGroup() { var testClass = new AttributeTestClass(); MethodInfo info = testClass.GetType().GetMethod("MethodWithoutAttributes"); Assert.IsNotNull(info); Assert.IsFalse(BaseMenuReportRegistrator.IsDenyInDataGroup(info)); }
public void TestAttributeForbiddenGroup() { var testClass = new AttributeTestClass(); MethodInfo info = testClass.GetType().GetMethod("ForbiddenAccessMethod"); Assert.IsNotNull(info); Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInDataGroup(info)); }
public void TestAttributeForbiddenOtherCustomization() { var testClass = new AttributeTestClass(); MethodInfo info = testClass.GetType().GetMethod("ForbiddenCustomizationOtherCountryMethod"); Assert.IsNotNull(info); Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInCustomization(info)); }
public void TestAttributeAllowedCustomizationCountry() { var testClass = new AttributeTestClass(); MethodInfo info = testClass.GetType().GetMethod("AllowedCustomizationCountryMethod"); Assert.IsNotNull(info); Assert.IsFalse(BaseMenuReportRegistrator.IsDenyInCustomization(info)); }
public void TestAttributes() { var s = new XmSerializerModel(); s.AddType(typeof(AttributeTestClass)); var obj = new AttributeTestClass { TestField = "foobar" }; var result = BasicTest.TestSerialization(obj, s); Assert.AreEqual(obj.TestField, result.TestField); }
public void TestAttributeCaption() { var testClass = new AttributeTestClass(); MethodInfo info = testClass.GetType().GetMethod("CaptionMethod"); Assert.IsNotNull(info); MenuReportDescriptionAttribute attribute = BaseMenuReportRegistrator.GetMenuActionDescriptionAttribute(info); Assert.IsNotNull(attribute); Assert.AreEqual("xxx", attribute.Caption); Assert.AreEqual(100, attribute.Order); }
public virtual void TestAttributesInheritance() { IUnityContainer container = this.GetContainer(); AttributeTestClass testClass = container.Resolve <AttributeTestClass>(); Type interceptedType = testClass.GetType(); Assert.AreNotEqual(typeof(AttributeTestClass), interceptedType); Assert.AreEqual(1, AttributeHelper.GetAttributes <InheritableTestAttribute>(interceptedType).Length); Assert.AreEqual(0, AttributeHelper.GetAttributes <InheritableTestAttribute>(interceptedType.GetMethod("TestMethod1")).Length); Assert.AreEqual(1, AttributeHelper.GetAttributes <InheritableTestAttribute>(interceptedType.GetMethod("TestMethod2")).Length); Assert.AreEqual(1, AttributeHelper.GetAttributes <InheritableTestAttribute>(interceptedType.GetProperty("TestProperty")).Length); Assert.AreEqual(1, AttributeHelper.GetAttributes <InheritableTestAttribute>(interceptedType.GetEvent("TestEvent")).Length); Assert.AreEqual(1, AttributeHelper.GetAttributes <InheritableTestAttribute>(interceptedType.GetProperty("Item")).Length); }
public virtual void TestAttributesMultiple() // bug 18951 { IUnityContainer container = this.GetContainer(); AttributeTestClass testClass = container.Resolve <AttributeTestClass>(); Type interceptedType = testClass.GetType(); Assert.AreNotEqual(typeof(AttributeTestClass), interceptedType); Assert.AreEqual(3, AttributeHelper.GetAttributes <MultipleTestAttribute>(interceptedType).Length); Assert.AreEqual(3, AttributeHelper.GetAttributes <MultipleTestAttribute>(interceptedType.GetMethod("TestMethod1")).Length); Assert.AreEqual(0, AttributeHelper.GetAttributes <MultipleTestAttribute>(interceptedType.GetMethod("TestMethod2")).Length); // Note: Known bug here. The expected values should all be 3. Appears to be a bug in the CLR reflection API. Assert.AreEqual(6, AttributeHelper.GetAttributes <MultipleTestAttribute>(interceptedType.GetProperty("TestProperty")).Length); //todo finds 6 Assert.AreEqual(6, AttributeHelper.GetAttributes <MultipleTestAttribute>(interceptedType.GetEvent("TestEvent")).Length); //todo finds 6 Assert.AreEqual(6, AttributeHelper.GetAttributes <MultipleTestAttribute>(interceptedType.GetProperty("Item")).Length); //todo finds 6 }
public void Attribute() { var context = new ObjectQueryContext(typeof(AttributeTestClass)); Assert.IsTrue(context.PropertyExists("@Foo", new AttributeTestClass())); var foo = new AttributeTestClass { Foo = "bar" }; Assert.IsTrue(context.PropertyExists("@Foo", foo)); Assert.IsFalse(context.PropertyExists("@Bar", foo)); var equality = false; context.VisitProperty("@Foo", foo, value => equality = value.Equals("bar")); Assert.IsTrue(equality); equality = false; context.VisitProperty("@Foo", new AttributeTestClass(), value => equality = value == null); Assert.IsTrue(equality); }
public void Attribute () { var context = new ObjectQueryContext (typeof (AttributeTestClass)); Assert.IsTrue (context.PropertyExists ("@Foo", new AttributeTestClass ())); var foo = new AttributeTestClass { Foo = "bar" }; Assert.IsTrue (context.PropertyExists ("@Foo", foo)); Assert.IsFalse (context.PropertyExists ("@Bar", foo)); var equality = false; context.VisitProperty ("@Foo", foo, value => equality = value.Equals ("bar")); Assert.IsTrue (equality); equality = false; context.VisitProperty ("@Foo", new AttributeTestClass (), value => equality = value == null); Assert.IsTrue (equality); }