public async Task OnPostAppMfaAsync_GivenCommandFails_ExpectPrgErrorStateAndRedirectToSamePage() { var mediator = new Mock <IMediator>(); mediator.Setup(x => x.Send(It.IsAny <AppMfaRequestedCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(ResultWithError.Fail(new ErrorData(ErrorCodes.AuthenticationFailed))); var authenticationService = new Mock <IAuthenticationService>(); var currentAuthenticatedUserProvider = new Mock <ICurrentAuthenticatedUserProvider>(); var page = new ValidateEmailMfaCode(mediator.Object, authenticationService.Object, currentAuthenticatedUserProvider.Object); Assert.IsType <RedirectToPageResult>(await page.OnPostAppMfaAsync()); Assert.Equal(PrgState.Failed, page.PrgState); }
public async Task OnPostAppMfaAsync_GivenCommandSucceeds_ExpectRedirectAppMfaPage() { var mediator = new Mock <IMediator>(); mediator.Setup(x => x.Send(It.IsAny <AppMfaRequestedCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(ResultWithError.Ok <ErrorData>()); var authenticationService = new Mock <IAuthenticationService>(); var currentAuthenticatedUserProvider = new Mock <ICurrentAuthenticatedUserProvider>(); var page = new ValidateEmailMfaCode(mediator.Object, authenticationService.Object, currentAuthenticatedUserProvider.Object); var result = Assert.IsType <RedirectToPageResult>(await page.OnPostAppMfaAsync()); Assert.Equal(PageLocations.AuthAppMfa, result.PageName); }