示例#1
0
        public void CheckClassLevelTest()
        {
            Type typeToTest = typeof(Demo);

            ClassLevelAttribute attribute = typeToTest.GetCustomAttribute <ClassLevelAttribute>();

            Assert.IsNotNull(attribute, "The ClassLevelAttribute is not set on type Demo");
            Assert.AreEqual(typeof(Demo), attribute.TypeWorkingFor, "the defined type is either null or not the type of TypeWorking for");
        }
示例#2
0
        public void IsImplementingInterfaceTestNegative()
        {
            ClassLevelAttribute attribute = new ClassLevelAttribute();

            attribute.TypeWorkingFor = typeof(string);

            attribute.IsImplementingInterface(null);

            //no assertion because the act must throw an exception
        }
示例#3
0
        public void IsImplementingInterfaceTestNegativeInvalidOperationException()
        {
            ClassLevelAttribute attribute = new ClassLevelAttribute();

            //attribute.TypeWorkingFor = typeof(string);

            attribute.IsImplementingInterface(typeof(IComparable));

            //no assertion because the act must throw an exception
        }
示例#4
0
        public void IsImplementingInterfaceTestPositiv()
        {
            //Arrange
            ClassLevelAttribute attribute = new ClassLevelAttribute
            {
                TypeWorkingFor = typeof(string)
            };

            Assert.IsTrue(attribute.IsImplementingInterface(typeof(IComparable)), "Type string does not implement IComparable");

            Assert.IsFalse(attribute.IsImplementingInterface(typeof(IDisposable)), "Type does implement IDisposable");
        }