Exemplo n.º 1
0
        public void TestAttributeAllowedCustomization()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("MethodWithoutAttributes");

            Assert.IsNotNull(info);

            Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInCustomization(info));

            info = testClass.GetType().GetMethod("AllowedCustomizationMethod");
            Assert.IsNotNull(info);

            Assert.IsFalse(BaseMenuReportRegistrator.IsDenyInCustomization(info));
        }
Exemplo n.º 2
0
        public void TestAttributeAllowedGroup()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("MethodWithoutAttributes");

            Assert.IsNotNull(info);

            Assert.IsFalse(BaseMenuReportRegistrator.IsDenyInDataGroup(info));
        }
Exemplo n.º 3
0
        public void TestAttributeForbiddenGroup()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("ForbiddenAccessMethod");

            Assert.IsNotNull(info);

            Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInDataGroup(info));
        }
Exemplo n.º 4
0
        public void TestAttributeForbiddenOtherCustomization()
        {
            var        testClass = new AttributeTestClass();
            MethodInfo info      = testClass.GetType().GetMethod("ForbiddenCustomizationOtherCountryMethod");

            Assert.IsNotNull(info);

            Assert.IsTrue(BaseMenuReportRegistrator.IsDenyInCustomization(info));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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
        }