diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index ae32784..0962e9e 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -23,6 +23,18 @@ You can read the original problem specification and discussion [here](https://g If your project has been impacted by this particular breaking change, you might consider reevaluate the correctness of the affected tests. +## Error Messages + +Some error messages surrounded actual values in double quotes. Others surrounded the values in single quotes. In version 3.0.0 *all* values are surrounded in single quotes. + +### Reason + +Consistency. + +### Fix + +Amend all effected tests to expect single quotes instead of double quotes. + # Version 2.0.0 ## ShouldRenderFileStream Method diff --git a/TestStack.FluentMVCTesting.Tests/ControllerExtensionsTests.cs b/TestStack.FluentMVCTesting.Tests/ControllerExtensionsTests.cs index 6c0d07d..6d19bfc 100644 --- a/TestStack.FluentMVCTesting.Tests/ControllerExtensionsTests.cs +++ b/TestStack.FluentMVCTesting.Tests/ControllerExtensionsTests.cs @@ -58,13 +58,13 @@ public void Check_for_unexpected_non_existent_temp_data_property() const string key = ""; var exception = Assert.Throws(() => - _controller.ShouldHaveTempDataProperty(key)); - - Assert.That(exception.Message, Is.EqualTo(string.Format( - "Expected TempData to have a non-null value with key \"{0}\", but none found.", key))); - } - - [Test] + _controller.ShouldHaveTempDataProperty(key)); + + Assert.That(exception.Message, Is.EqualTo(string.Format( + "Expected TempData to have a non-null value with key '{0}', but none found.", key))); + } + + [Test] public void Check_for_existent_temp_data_property_and_check_value() { const string key = ""; @@ -82,13 +82,13 @@ public void Check_for_existent_temp_data_property_and_check_invalid_value() const int expectedValue = 1; _controller.TempData[key] = actualValue; - var exception = Assert.Throws(() => - _controller.ShouldHaveTempDataProperty(key, expectedValue)); - - Assert.That(exception.Message, Is.EqualTo(string.Format("Expected value for key \"{0}\" to be \"{1}\", but instead found \"{2}\"", key, expectedValue, actualValue))); - } - - [Test] + var exception = Assert.Throws(() => + _controller.ShouldHaveTempDataProperty(key, expectedValue)); + + Assert.That(exception.Message, Is.EqualTo(string.Format("Expected value for key '{0}' to be '{1}', but instead found '{2}'", key, expectedValue, actualValue))); + } + + [Test] public void Check_for_existent_temp_data_property_and_check_invalid_value_of_different_types() { const string key = ""; @@ -141,13 +141,13 @@ public void Check_for_unexpected_non_existent_temp_data_property_when_supplied_w const string key = ""; var exception = Assert.Throws(() => - _controller.ShouldHaveTempDataProperty(key, x => x == 0)); - - Assert.That(exception.Message, Is.EqualTo(string.Format( - "Expected TempData to have a non-null value with key \"{0}\", but none found.", key))); - } - - [Test] + _controller.ShouldHaveTempDataProperty(key, x => x == 0)); + + Assert.That(exception.Message, Is.EqualTo(string.Format( + "Expected TempData to have a non-null value with key '{0}', but none found.", key))); + } + + [Test] public void Check_for_non_existent_temp_data_property() { _controller @@ -161,10 +161,10 @@ public void Check_for_unexpected_existent_temp_data_property() _controller.TempData[Key] = ""; var exception = Assert.Throws(() => - _controller.ShouldNotHaveTempDataProperty(Key)); - - Assert.That(exception.Message, Is.EqualTo(string.Format( - "Expected TempData to have no value with key \"{0}\", but found one.", Key))); - } - } -} + _controller.ShouldNotHaveTempDataProperty(Key)); + + Assert.That(exception.Message, Is.EqualTo(string.Format( + "Expected TempData to have no value with key '{0}', but found one.", Key))); + } + } +} diff --git a/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldRenderFileTests.cs b/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldRenderFileTests.cs index 3034cd9..2872519 100644 --- a/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldRenderFileTests.cs +++ b/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldRenderFileTests.cs @@ -104,7 +104,7 @@ public void Check_for_file_content_result_and_check_invalid_textual_contents() var exception = Assert.Throws(() => _controller.WithCallTo(c => c.TextualFile()).ShouldRenderFileContents(contents)); - Assert.That(exception.Message, Is.EqualTo(string.Format("Expected file contents to be \"{0}\", but instead was \"{1}\".", contents, ControllerResultTestController.TextualFileContent))); + Assert.That(exception.Message, Is.EqualTo(string.Format("Expected file contents to be '{0}', but instead was '{1}'.", contents, ControllerResultTestController.TextualFileContent))); } [Test] @@ -309,7 +309,7 @@ public void Check_for_file_stream_result_and_check_invalid_textual_content() var exception = Assert.Throws(() => _controller.WithCallTo(c => c.TextualStream()).ShouldRenderFileStream(contents)); - Assert.That(exception.Message, Is.EqualTo(string.Format("Expected file contents to be \"{0}\", but instead was \"{1}\".", contents, ControllerResultTestController.TextualFileContent))); + Assert.That(exception.Message, Is.EqualTo(string.Format("Expected file contents to be '{0}', but instead was '{1}'.", contents, ControllerResultTestController.TextualFileContent))); } [Test] diff --git a/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldReturnContentTests.cs b/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldReturnContentTests.cs index d637b7d..a9870a6 100644 --- a/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldReturnContentTests.cs +++ b/TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldReturnContentTests.cs @@ -26,7 +26,7 @@ public void Check_for_content_result_and_check_invalid_content() var exception = Assert.Throws(() => _controller.WithCallTo(c => c.Content()).ShouldReturnContent(content)); - Assert.That(exception.Message, Is.EqualTo(string.Format("Expected content to be \"{0}\", but instead was \"{1}\".", content, ControllerResultTestController.TextualContent))); + Assert.That(exception.Message, Is.EqualTo(string.Format("Expected content to be '{0}', but instead was '{1}'.", content, ControllerResultTestController.TextualContent))); } [Test] @@ -42,7 +42,7 @@ public void Check_for_content_result_and_check_content_and_check_invalid_content var exception = Assert.Throws(() => _controller.WithCallTo(c => c.Content()).ShouldReturnContent(ControllerResultTestController.TextualContent, contentType)); - Assert.That(exception.Message, Is.EqualTo(string.Format("Expected content type to be \"{0}\", but instead was \"{1}\".", contentType, ControllerResultTestController.ContentType))); + Assert.That(exception.Message, Is.EqualTo(string.Format("Expected content type to be '{0}', but instead was '{1}'.", contentType, ControllerResultTestController.ContentType))); } [Test] diff --git a/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs b/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs index 2e483df..4dfd805 100644 --- a/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs +++ b/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs @@ -35,7 +35,7 @@ public void Check_for_unexpected_non_existent_temp_data_property() _tempDataTest.AndShouldHaveTempDataProperty(key)); Assert.That(exception.Message, Is.EqualTo(string.Format( - "Expected TempData to have a non-null value with key \"{0}\", but none found.", key))); + "Expected TempData to have a non-null value with key '{0}', but none found.", key))); } [Test] @@ -59,7 +59,7 @@ public void Check_for_existent_temp_data_property_and_check_invalid_value() var exception = Assert.Throws(() => _tempDataTest.AndShouldHaveTempDataProperty(key, expectedValue)); - Assert.That(exception.Message, Is.EqualTo(string.Format("Expected value for key \"{0}\" to be \"{1}\", but instead found \"{2}\"", key, expectedValue, actualValue))); + Assert.That(exception.Message, Is.EqualTo(string.Format("Expected value for key '{0}' to be '{1}', but instead found '{2}'", key, expectedValue, actualValue))); } [Test] @@ -117,7 +117,7 @@ public void Check_for_non_existent_temp_data_property_when_supplied_with_predica _tempDataTest.AndShouldHaveTempDataProperty(key, x => x == 0)); Assert.That(exception.Message, Is.EqualTo(string.Format( - "Expected TempData to have a non-null value with key \"{0}\", but none found.", key))); + "Expected TempData to have a non-null value with key '{0}', but none found.", key))); } [Test] @@ -137,7 +137,7 @@ public void Check_for_unexpected_existent_temp_data_property() _tempDataTest.AndShouldNotHaveTempDataProperty(Key)); Assert.That(exception.Message, Is.EqualTo(string.Format( - "Expected TempData to have no value with key \"{0}\", but found one.", Key))); + "Expected TempData to have no value with key '{0}', but found one.", Key))); } [Test] diff --git a/TestStack.FluentMvcTesting/ControllerExtensions.cs b/TestStack.FluentMvcTesting/ControllerExtensions.cs index ae430a9..4c377c8 100644 --- a/TestStack.FluentMvcTesting/ControllerExtensions.cs +++ b/TestStack.FluentMvcTesting/ControllerExtensions.cs @@ -64,13 +64,13 @@ public static TempDataResultTest ShouldHaveTempDataProperty(this ControllerBase { var actual = controller.TempData[key]; - if (actual == null) - { - throw new TempDataAssertionException(string.Format( - "Expected TempData to have a non-null value with key \"{0}\", but none found.", key)); - } - - if (value != null && actual.GetType() != value.GetType()) + if (actual == null) + { + throw new TempDataAssertionException(string.Format( + "Expected TempData to have a non-null value with key '{0}', but none found.", key)); + } + + if (value != null && actual.GetType() != value.GetType()) { throw new TempDataAssertionException(string.Format( "Expected value to be of type {0}, but instead was {1}.", @@ -78,26 +78,26 @@ public static TempDataResultTest ShouldHaveTempDataProperty(this ControllerBase actual.GetType().FullName)); } - if (value != null && !value.Equals(actual)) - { - throw new TempDataAssertionException(string.Format( - "Expected value for key \"{0}\" to be \"{1}\", but instead found \"{2}\"", key, value, actual)); - } - - return new TempDataResultTest(controller); + if (value != null && !value.Equals(actual)) + { + throw new TempDataAssertionException(string.Format( + "Expected value for key '{0}' to be '{1}', but instead found '{2}'", key, value, actual)); + } + + return new TempDataResultTest(controller); } public static TempDataResultTest ShouldHaveTempDataProperty(this ControllerBase controller, string key, Func predicate) { var actual = controller.TempData[key]; - if (actual == null) - { - throw new TempDataAssertionException(string.Format( - "Expected TempData to have a non-null value with key \"{0}\", but none found.", key)); - } - - if (!predicate((TValue)actual)) + if (actual == null) + { + throw new TempDataAssertionException(string.Format( + "Expected TempData to have a non-null value with key '{0}', but none found.", key)); + } + + if (!predicate((TValue)actual)) { throw new TempDataAssertionException("Expected view model to pass the given condition, but it failed."); } @@ -109,13 +109,13 @@ public static TempDataResultTest ShouldNotHaveTempDataProperty(this ControllerBa { var actual = controller.TempData[key]; - if (actual != null) - { - throw new TempDataAssertionException(string.Format( - "Expected TempData to have no value with key \"{0}\", but found one.", key)); - } - - return new TempDataResultTest(controller); + if (actual != null) + { + throw new TempDataAssertionException(string.Format( + "Expected TempData to have no value with key '{0}', but found one.", key)); + } + + return new TempDataResultTest(controller); } } diff --git a/TestStack.FluentMvcTesting/ControllerResultTest/ShouldRenderFile.cs b/TestStack.FluentMvcTesting/ControllerResultTest/ShouldRenderFile.cs index b12207b..04eb8a8 100644 --- a/TestStack.FluentMvcTesting/ControllerResultTest/ShouldRenderFile.cs +++ b/TestStack.FluentMvcTesting/ControllerResultTest/ShouldRenderFile.cs @@ -69,7 +69,7 @@ public FileContentResult ShouldRenderFileContents(string contents, string conten if (contents != reconstitutedText) { throw new ActionResultAssertionException(string.Format( - "Expected file contents to be \"{0}\", but instead was \"{1}\".", + "Expected file contents to be '{0}', but instead was '{1}'.", contents, reconstitutedText)); } @@ -121,7 +121,7 @@ public FileStreamResult ShouldRenderFileStream(string contents, string contentTy if (contents != reconstitutedText) { throw new ActionResultAssertionException(string.Format( - "Expected file contents to be \"{0}\", but instead was \"{1}\".", + "Expected file contents to be '{0}', but instead was '{1}'.", contents, reconstitutedText)); } diff --git a/TestStack.FluentMvcTesting/ControllerResultTest/ShouldReturnContent.cs b/TestStack.FluentMvcTesting/ControllerResultTest/ShouldReturnContent.cs index a8f365e..3101154 100644 --- a/TestStack.FluentMvcTesting/ControllerResultTest/ShouldReturnContent.cs +++ b/TestStack.FluentMvcTesting/ControllerResultTest/ShouldReturnContent.cs @@ -13,7 +13,7 @@ public ContentResult ShouldReturnContent(string content = null, string contentTy if (contentType != null && contentType != contentResult.ContentType) { throw new ActionResultAssertionException(string.Format( - "Expected content type to be \"{0}\", but instead was \"{1}\".", + "Expected content type to be '{0}', but instead was '{1}'.", contentType, contentResult.ContentType)); } @@ -21,7 +21,7 @@ public ContentResult ShouldReturnContent(string content = null, string contentTy if (content != null && content != contentResult.Content) { throw new ActionResultAssertionException(string.Format( - "Expected content to be \"{0}\", but instead was \"{1}\".", + "Expected content to be '{0}', but instead was '{1}'.", content, contentResult.Content)); }