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"); }
public void IsImplementingInterfaceTestNegative() { ClassLevelAttribute attribute = new ClassLevelAttribute(); attribute.TypeWorkingFor = typeof(string); attribute.IsImplementingInterface(null); //no assertion because the act must throw an exception }
public void IsImplementingInterfaceTestNegativeInvalidOperationException() { ClassLevelAttribute attribute = new ClassLevelAttribute(); //attribute.TypeWorkingFor = typeof(string); attribute.IsImplementingInterface(typeof(IComparable)); //no assertion because the act must throw an exception }
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"); }