Skip to content

Commit 7df9316

Browse files
committed
Improved test coverage.
1 parent 1eb05aa commit 7df9316

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

TestStack.FluentMVCTesting.Tests/ControllerExtensionsTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,17 @@ public void Check_for_existent_temp_data_property_and_check_value_using_invalid_
134134

135135
Assert.That(exception.Message, Is.EqualTo("Expected view model to pass the given condition, but it failed."));
136136
}
137+
138+
[Test]
139+
public void Check_for_non_existent_temp_data_property_when_supplied_with_predicate()
140+
{
141+
const string key = "";
142+
143+
var exception = Assert.Throws<TempDataAssertionException>(() =>
144+
_controller.ShouldHaveTempDataProperty<int>(key, x => x == 0));
145+
146+
Assert.That(exception.Message, Is.EqualTo(string.Format(
147+
"Expected TempData to have a non-null value with key \"{0}\", but none found.", key)));
148+
}
137149
}
138150
}

TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,17 @@ public void Check_for_existent_temp_data_property_and_check_value_using_invalid_
107107

108108
Assert.That(exception.Message, Is.EqualTo("Expected view model to pass the given condition, but it failed."));
109109
}
110+
111+
[Test]
112+
public void Check_for_non_existent_temp_data_property_when_supplied_with_predicate()
113+
{
114+
const string key = "";
115+
116+
var exception = Assert.Throws<TempDataAssertionException>(() =>
117+
_tempDataTest.AndShouldHaveTempDataProperty<int>(key, x => x == 0));
118+
119+
Assert.That(exception.Message, Is.EqualTo(string.Format(
120+
"Expected TempData to have a non-null value with key \"{0}\", but none found.", key)));
121+
}
110122
}
111123
}

0 commit comments

Comments
 (0)