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);
        }
예제 #3
0
        public void TestAttributeAllowedGroup()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("MethodWithoutAttributes");

            Assert.IsNotNull(info);

            Assert.IsFalse(BaseMenuReportRegistrator.IsDenyInDataGroup(info));
        }
예제 #4
0
        public void TestAttributeForbiddenGroup()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("ForbiddenAccessMethod");

            Assert.IsNotNull(info);

            Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInDataGroup(info));
        }
예제 #5
0
        public void TestAttributeForbiddenOtherCustomization()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("ForbiddenCustomizationOtherCountryMethod");

            Assert.IsNotNull(info);

            Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInCustomization(info));
        }
예제 #6
0
        public void TestAttributeAllowedCustomizationCountry()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("AllowedCustomizationCountryMethod");

            Assert.IsNotNull(info);

            Assert.IsFalse(BaseMenuReportRegistrator.IsDenyInCustomization(info));
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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
        }
예제 #11
0
        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);
        }
예제 #12
0
 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);
 }