public void Constructor_GivenNullParameter_ShouldThrowArgumentNullException(string parameterName) { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- ConstructorTestHelper.ValidateArgumentNullExceptionIfParameterIsNull <DataAccessParameter>(parameterName); //---------------Test Result ----------------------- }
public void ValidateArgumentNullExceptionIfParameterIsNull_GivenParameterWhereExceptionIsThrownAndParameterValues_ShouldPassTest(string parameterName) { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => ConstructorTestHelper.ValidateArgumentNullExceptionIfParameterIsNull <FakeTestClass>(parameterName, ("testDateTime", DateTime.Now))); //---------------Test Result ----------------------- }
public void ValidateArgumentNullExceptionIfParameterIsNull_GivenParameterWhereExceptionIsNotThrown_ShouldFailTest() { //---------------Set up test pack------------------- var parameterName = "complexObjectNotTested"; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var exception = Assert.Throws <AssertionException>(() => ConstructorTestHelper.ValidateArgumentNullExceptionIfParameterIsNull <FakeTestClass>(parameterName)); //---------------Test Result ----------------------- exception.Message.Should().Be($"ArgumentNullException not throw for Constructor Parameter [{parameterName}] on {typeof(FakeTestClass).FullName}"); }
public void ValidateArgumentNullExceptionIfParameterIsNull_GivenParameterValuesAndExceptionNotThrown_ShouldFailTest() { //---------------Set up test pack------------------- var parameterName = "notSetParameter"; var testDateTime = DateTime.Now; var fakeComplex = new FakeComplex(); var parameterValues = new List <(string paramName, object paramValue)> { ("testDateTime", testDateTime), ("complexObject", fakeComplex) }; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var exception = Assert.Throws <AssertionException>(() => ConstructorTestHelper.ValidateArgumentNullExceptionIfParameterIsNull <FakeTestClass>(parameterName, parameterValues.ToArray())); //---------------Test Result ----------------------- exception.Message.Should().Contain($"ArgumentNullException not throw for Constructor Parameter [{parameterName}] on {typeof(FakeTestClass).FullName}"); }