/// <summary> /// Asserts that the Items contain the the expected Key Value Pair. /// </summary> /// <param name="expectedKey">The expected Key in Items.</param> /// <param name="expectedValue">The expected Value in Items.</param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> public ChallengeResultAssertions ContainsItem(string expectedKey, string expectedValue, string reason = "", params object[] reasonArgs) { var actualItems = Items; AssertionHelpers.AssertStringObjectDictionary(actualItems, "ChallengeResult.AuthenticationProperties.Items", expectedKey, expectedValue, reason, reasonArgs); return(this); }
public RedirectToRouteAssertions WithRouteValue(string key, object expectedValue, string reason = "", params object[] reasonArgs) { var routeValues = Subject.RouteValues; AssertionHelpers.AssertStringObjectDictionary(routeValues, "RedirectToRouteResult.RouteValues", key, expectedValue, reason, reasonArgs); return(this); }
/// <summary> /// Asserts that the route data has the expected data token. /// </summary> /// <param name="key">The expected data token key value.</param> /// <param name="expectedValue">The expected data token value.</param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> public RouteDataAssertions HaveDataToken(string key, object expectedValue, string reason = "", params object[] reasonArgs) { var subjectTyped = Subject as RouteData; AssertionHelpers.AssertStringObjectDictionary(subjectTyped.DataTokens, "RouteData.DataTokens", key, expectedValue, reason, reasonArgs); return(this); }
/// <summary> /// Asserts that the redirect has the expected route value. /// </summary> /// <param name="key">The expected key.</param> /// <param name="expectedValue">The expected value.</param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> public RedirectToActionResultAssertions WithRouteValue(string key, object expectedValue, string reason = "", params object[] reasonArgs) { var subjectTyped = RedirectToActionResultSubject; AssertionHelpers.AssertStringObjectDictionary(subjectTyped.RouteValues, "RedirectToActionResult.RouteValues", key, expectedValue, reason, reasonArgs); return(this); }
/// <summary> /// Asserts that the redirect has the expected route value. /// </summary> /// <param name="key">The expected key.</param> /// <param name="expectedValue">The expected value.</param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> public AcceptedAtRouteResultAssertions WithRouteValue(string key, object expectedValue, string reason = "", params object[] reasonArgs) { var actualRouteValues = ObjectResultSubject.RouteValues; AssertionHelpers.AssertStringObjectDictionary(actualRouteValues, "AcceptedAtRouteResult.RouteValues", key, expectedValue, reason, reasonArgs); return(this); }
/// <summary> /// Asserts that the temp data contains the expected data. /// </summary> /// <param name="key">The expected temp data key.</param> /// <param name="expectedValue">The expected temp data.</param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> public PartialViewResultAssertions WithTempData(string key, object expectedValue, string reason = "", params object[] reasonArgs) { var actualTempData = PartialViewResultSubject.TempData; AssertionHelpers.AssertStringObjectDictionary(actualTempData, "PartialViewResult.TempData", key, expectedValue, reason, reasonArgs); return(this); }
/// <summary> /// Asserts the uri has the expected value. /// </summary> /// <param name="uri"> /// The Uri. /// </param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> /// <returns>The typed value.</returns> public AcceptedResultAssertions WithUri(Uri uri, string reason = "", params object[] reasonArgs) { var expectedUri = AssertionHelpers.GetAbsoluteUri(uri); Execute.Assertion .BecauseOf(reason, reasonArgs) .ForCondition(expectedUri == Location) .WithDefaultIdentifier("AcceptedResult.Uri") .FailWith(FailureMessages.CommonFailMessage, expectedUri, Location); return(this); }
/// <summary> /// Asserts that the IssuedUtc is exactly the same as the expected IssuedUtc. /// </summary> /// <param name="expectedIssuedUtc">The expected IssuedUtc.</param> /// <param name="reason"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="reasonArgs"> /// Zero or more objects to format using the placeholders in <paramref name="reason"/>. /// </param> public SignOutResultAssertions WithIssuedUtc(DateTimeOffset?expectedIssuedUtc, string reason = "", params object[] reasonArgs) { var actualResult = IssuedUtc; DateTimeOffset?expectedResult = AssertionHelpers.RoundToSeconds(expectedIssuedUtc); Execute.Assertion .ForCondition(expectedResult == actualResult) .BecauseOf(reason, reasonArgs) .WithDefaultIdentifier("SignOutResult.AuthenticationProperties.IssuedUtc") .FailWith(FailureMessages.CommonFailMessage, expectedResult, actualResult); return(this); }