Skip to content

Implemented AndShouldNotHaveTempDataProperty method #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 28, 2014
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;
}
}
}