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 ----------------------- }
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"); }
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 ----------------------- }
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"); }