Esempio n. 1
0
        public async Task OnPost_GivenInvalidModelState_ExpectRedirectToPageResult()
        {
            var mediator = new Mock <IMediator>();

            var page = new RequestAccountVerification(mediator.Object)
            {
                PageModel = new RequestAccountVerification.Model()
            };

            page.ModelState.AddModelError("Error", "Error");

            var result = await page.OnPostAsync();

            Assert.IsType <RedirectToPageResult>(result);
        }
Esempio n. 2
0
        public async Task OnPost_GivenValidModelState_ExpectRedirectToPageResultToTheSamePage()
        {
            var mediator = new Mock <IMediator>();

            var page = new RequestAccountVerification(mediator.Object)
            {
                PageModel = new RequestAccountVerification.Model()
            };

            Assert.IsType <RedirectToPageResult>(await page.OnPostAsync());

            Assert.Equal(PrgState.Success, page.PrgState);
            mediator.Verify(
                x => x.Send(It.IsAny <RequestAccountVerificationCommand>(), It.IsAny <CancellationToken>()),
                Times.Once);
        }