From e377030d6918231597a5f60838f6e3e18d7659da Mon Sep 17 00:00:00 2001 From: ByteBlast Date: Tue, 2 Dec 2014 12:29:02 +0000 Subject: [PATCH 1/2] Tweaked the ShouldNotHaveTempDataProperty method signature. --- TestStack.FluentMvcTesting/ControllerExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestStack.FluentMvcTesting/ControllerExtensions.cs b/TestStack.FluentMvcTesting/ControllerExtensions.cs index 55835d6..ae430a9 100644 --- a/TestStack.FluentMvcTesting/ControllerExtensions.cs +++ b/TestStack.FluentMvcTesting/ControllerExtensions.cs @@ -105,7 +105,7 @@ public static TempDataResultTest ShouldHaveTempDataProperty(this Control return new TempDataResultTest(controller); } - public static TempDataResultTest ShouldNotHaveTempDataProperty(this Controller controller, string key) + public static TempDataResultTest ShouldNotHaveTempDataProperty(this ControllerBase controller, string key) { var actual = controller.TempData[key]; From a3ca30a9220292470bcfdb4170f32a6547fa7b64 Mon Sep 17 00:00:00 2001 From: ByteBlast Date: Tue, 2 Dec 2014 12:36:09 +0000 Subject: [PATCH 2/2] Implemented AndShouldNotHaveTempDataProperty method. Further implementation of #36. --- .../TempDataResultTest.cs | 30 ++++++++++++++++++- .../TempDataResultTest.cs | 6 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs b/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs index d97f0f9..2e483df 100644 --- a/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs +++ b/TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs @@ -27,7 +27,7 @@ public void Check_for_existent_temp_data_property() } [Test] - public void Check_for_non_existent_temp_data_property() + public void Check_for_unexpected_non_existent_temp_data_property() { const string key = ""; @@ -119,5 +119,33 @@ public void Check_for_non_existent_temp_data_property_when_supplied_with_predica 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() + { + _tempDataTest + .AndShouldNotHaveTempDataProperty(""); + } + + [Test] + public void Check_for_unexpected_existent_temp_data_property() + { + const string Key = ""; + _controller.TempData[Key] = ""; + + var exception = Assert.Throws(() => + _tempDataTest.AndShouldNotHaveTempDataProperty(Key)); + + Assert.That(exception.Message, Is.EqualTo(string.Format( + "Expected TempData to have no value with key \"{0}\", but found one.", Key))); + } + + [Test] + public void Return_the_same_temp_data_result() + { + var actual = _tempDataTest + .AndShouldNotHaveTempDataProperty(""); + Assert.That(actual, Is.SameAs(_tempDataTest)); + } } } \ No newline at end of file diff --git a/TestStack.FluentMvcTesting/TempDataResultTest.cs b/TestStack.FluentMvcTesting/TempDataResultTest.cs index 013378b..6e1406f 100644 --- a/TestStack.FluentMvcTesting/TempDataResultTest.cs +++ b/TestStack.FluentMvcTesting/TempDataResultTest.cs @@ -23,5 +23,11 @@ public TempDataResultTest AndShouldHaveTempDataProperty(string key, Func _controller.ShouldHaveTempDataProperty(key, predicate); return this; } + + public TempDataResultTest AndShouldNotHaveTempDataProperty(string empty) + { + _controller.ShouldNotHaveTempDataProperty(empty); + return this; + } } } \ No newline at end of file