Skip to content

Commit a3ca30a

Browse files
committed
Implemented AndShouldNotHaveTempDataProperty method.
Further implementation of #36.
1 parent e377030 commit a3ca30a

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
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/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)