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/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]; 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