Skip to content

Commit 6944eba

Browse files
committed
Merge pull request #49 from ByteBlast/master
Implemented AndShouldNotHaveTempDataProperty method
2 parents 144bc4e + a3ca30a commit 6944eba

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

TestStack.FluentMVCTesting.Tests/TempDataResultTest.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Check_for_existent_temp_data_property()
2727
}
2828

2929
[Test]
30-
public void Check_for_non_existent_temp_data_property()
30+
public void Check_for_unexpected_non_existent_temp_data_property()
3131
{
3232
const string key = "";
3333

@@ -119,5 +119,33 @@ public void Check_for_non_existent_temp_data_property_when_supplied_with_predica
119119
Assert.That(exception.Message, Is.EqualTo(string.Format(
120120
"Expected TempData to have a non-null value with key \"{0}\", but none found.", key)));
121121
}
122+
123+
[Test]
124+
public void Check_for_non_existent_temp_data_property()
125+
{
126+
_tempDataTest
127+
.AndShouldNotHaveTempDataProperty("");
128+
}
129+
130+
[Test]
131+
public void Check_for_unexpected_existent_temp_data_property()
132+
{
133+
const string Key = "";
134+
_controller.TempData[Key] = "";
135+
136+
var exception = Assert.Throws<TempDataAssertionException>(() =>
137+
_tempDataTest.AndShouldNotHaveTempDataProperty(Key));
138+
139+
Assert.That(exception.Message, Is.EqualTo(string.Format(
140+
"Expected TempData to have no value with key \"{0}\", but found one.", Key)));
141+
}
142+
143+
[Test]
144+
public void Return_the_same_temp_data_result()
145+
{
146+
var actual = _tempDataTest
147+
.AndShouldNotHaveTempDataProperty("");
148+
Assert.That(actual, Is.SameAs(_tempDataTest));
149+
}
122150
}
123151
}

TestStack.FluentMvcTesting/ControllerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static TempDataResultTest ShouldHaveTempDataProperty<TValue>(this Control
105105
return new TempDataResultTest(controller);
106106
}
107107

108-
public static TempDataResultTest ShouldNotHaveTempDataProperty(this Controller controller, string key)
108+
public static TempDataResultTest ShouldNotHaveTempDataProperty(this ControllerBase controller, string key)
109109
{
110110
var actual = controller.TempData[key];
111111

TestStack.FluentMvcTesting/TempDataResultTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ public TempDataResultTest AndShouldHaveTempDataProperty<TValue>(string key, Func
2323
_controller.ShouldHaveTempDataProperty(key, predicate);
2424
return this;
2525
}
26+
27+
public TempDataResultTest AndShouldNotHaveTempDataProperty(string empty)
28+
{
29+
_controller.ShouldNotHaveTempDataProperty(empty);
30+
return this;
31+
}
2632
}
2733
}

0 commit comments

Comments
 (0)