Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";

Expand Down Expand Up @@ -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<TempDataAssertionException>(() =>
_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));
}
}
}
2 changes: 1 addition & 1 deletion TestStack.FluentMvcTesting/ControllerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static TempDataResultTest ShouldHaveTempDataProperty<TValue>(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];

Expand Down
6 changes: 6 additions & 0 deletions TestStack.FluentMvcTesting/TempDataResultTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ public TempDataResultTest AndShouldHaveTempDataProperty<TValue>(string key, Func
_controller.ShouldHaveTempDataProperty(key, predicate);
return this;
}

public TempDataResultTest AndShouldNotHaveTempDataProperty(string empty)
{
_controller.ShouldNotHaveTempDataProperty(empty);
return this;
}
}
}