예제 #1
0
 public void ValidateDecoratedWithAttribute_GivenPropertyDecorated_ShouldPassTest(string propertyName, Type attributeType)
 {
     //---------------Set up test pack-------------------
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     Assert.DoesNotThrow(() => PropertyTestHelper.ValidateDecoratedWithAttribute <FakeTestClass>(propertyName, attributeType));
     //---------------Test Result -----------------------
 }
예제 #2
0
        public void ValidateDecoratedWithAttribute_GivenPropertyNotDecorated_ShouldFailTest(string propertyName, Type attributeType)
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var exception = Assert.Throws <AssertionException>(() => PropertyTestHelper.ValidateDecoratedWithAttribute <FakeTestClass>(propertyName, attributeType));

            //---------------Test Result -----------------------
            exception.Message.Contains($"Property {propertyName} is not decorated with {attributeType.Name} Attribute");
        }
예제 #3
0
 public void ValidateDecoratedWithAttribute_GivenPropertyDecoratedWithAttributeWithExpectedParameters_ShouldPassTest()
 {
     //---------------Set up test pack-------------------
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     Assert.DoesNotThrow(() => PropertyTestHelper.ValidateDecoratedWithAttribute <FakeTestClass>("TestDictionary",
                                                                                                 typeof(FakeTestAttribute),
                                                                                                 new List <(string propertyName, object propertyValue)>
     {
         ("PropertyName", "TestDictionary"),
         ("Sequence", 23)
     }));
     //---------------Test Result -----------------------
 }
예제 #4
0
        public void ValidateDecoratedWithAttribute_GivenPropertyDecoratedWithAttributeButPropertyValueIsNotExpected_ShouldFailTest()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var exception = Assert.Throws <AssertionException>(() => PropertyTestHelper.ValidateDecoratedWithAttribute <FakeTestClass>("TestDictionary",
                                                                                                                                       typeof(FakeTestAttribute),
                                                                                                                                       new List <(string propertyName, object propertyValue)>
            {
                ("PropertyName", "TestDictionary"),
                ("Sequence", 55)
            }));

            //---------------Test Result -----------------------
            exception.Message.Should().Contain("TestDictionary Property is decorated with FakeTestAttribute " +
                                               "but the attribute property Sequence is not set to 55");
        }