|
1 |
| -using System; |
2 |
| -using System.Collections.Generic; |
3 |
| -using System.Globalization; |
4 |
| -using FluentAssertions.Mvc.Tests.Helpers; |
| 1 | +using FluentAssertions.Mvc.Tests.Helpers; |
5 | 2 | using Microsoft.AspNetCore.Authentication;
|
6 | 3 | using Microsoft.AspNetCore.Mvc;
|
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Globalization; |
7 | 7 | using Xunit;
|
8 | 8 |
|
9 | 9 | namespace FluentAssertions.AspNetCore.Mvc.Tests
|
@@ -285,19 +285,50 @@ public void ContainsItem_GivenExpected_ShouldPass()
|
285 | 285 | }
|
286 | 286 |
|
287 | 287 | [Fact]
|
288 |
| - public void ContainsItem_GivenUnexpected_ShouldFail() |
| 288 | + public void ContainsItem_GivenNull_ShouldFail() |
| 289 | + { |
| 290 | + const string testKey = "testKey"; |
| 291 | + const string testValue = "testValue"; |
| 292 | + ActionResult result = new SignOutResult(TestAuthenticationSchemes); |
| 293 | + var failureMessage = FailureMessageHelper.ExpectedContextContainValueAtKeyButFoundNull( |
| 294 | + "SignOutResult.AuthenticationProperties.Items", testValue, testKey); |
| 295 | + |
| 296 | + Action a = () => result.Should().BeSignOutResult().ContainsItem(testKey, testValue, Reason, ReasonArgs); |
| 297 | + |
| 298 | + a.Should().Throw<Exception>().WithMessage(failureMessage); |
| 299 | + } |
| 300 | + |
| 301 | + [Fact] |
| 302 | + public void ContainsItem_GivenUnexpectedKey_ShouldFail() |
289 | 303 | {
|
290 | 304 | const string testKey = "testKey";
|
291 | 305 | const string testValue = "testValue";
|
292 | 306 | const string expectedKey = "wrong key";
|
293 |
| - const string expectedValue = "wrong value"; |
| 307 | + var properties = new Dictionary<string, string> { { testKey, testValue } }; |
| 308 | + var actualAuthenticationProperties = new AuthenticationProperties(properties); |
| 309 | + ActionResult result = new SignOutResult(TestAuthenticationSchemes, actualAuthenticationProperties); |
| 310 | + var failureMessage = FailureMessageHelper.ExpectedContextContainValueAtKeyButKeyNotFound( |
| 311 | + "SignOutResult.AuthenticationProperties.Items", testValue, expectedKey); |
| 312 | + |
| 313 | + Action a = () => result.Should().BeSignOutResult().ContainsItem(expectedKey, testValue, Reason, ReasonArgs); |
| 314 | + |
| 315 | + a.Should().Throw<Exception>().WithMessage(failureMessage); |
| 316 | + } |
294 | 317 |
|
| 318 | + [Fact] |
| 319 | + public void ContainsItem_GivenUnexpectedValue_ShouldFail() |
| 320 | + { |
| 321 | + const string testKey = "testKey"; |
| 322 | + const string testValue = "testValue"; |
| 323 | + const string expectedValue = "wrong value"; |
295 | 324 | var properties = new Dictionary<string, string> { { testKey, testValue } };
|
296 | 325 | var actualAuthenticationProperties = new AuthenticationProperties(properties);
|
297 | 326 | ActionResult result = new SignOutResult(TestAuthenticationSchemes, actualAuthenticationProperties);
|
298 |
| - var failureMessage = string.Format(FailureMessages.CommonItemsContain, expectedKey, expectedValue); |
| 327 | + var failureMessage = FailureMessageHelper.ExpectedAtKeyValueXButFoundY( |
| 328 | + "SignOutResult.AuthenticationProperties.Items", testKey, expectedValue, testValue); |
| 329 | + |
| 330 | + Action a = () => result.Should().BeSignOutResult().ContainsItem(testKey, expectedValue, Reason, ReasonArgs); |
299 | 331 |
|
300 |
| - Action a = () => result.Should().BeSignOutResult().ContainsItem(expectedKey, expectedValue, Reason, ReasonArgs); |
301 | 332 | a.Should().Throw<Exception>().WithMessage(failureMessage);
|
302 | 333 | }
|
303 | 334 |
|
|
0 commit comments