コード例 #1
0
        public async Task SendSignUpMessageAsync_ShouldReturnBadRequest_WithModelState_WhenUserIsNotFound()
        {
            var signUpMessageSenderMock = new Mock <ISignUpMessageSender>();
            var userStoreMock           = new Mock <IUserStore <User> >();
            var userManagerMock         = new Mock <UserManager <User> >(userStoreMock.Object, null, null, null, null, null, null, null, null);

            using (var controller = new SignUpController(userManagerMock.Object, null, signUpMessageSenderMock.Object))
            {
                IActionResult actionResult = await controller.SendEmailMessageAsync(new SignUpSendEmailMessageViewModel());

                var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(actionResult);
                Assert.IsType <SerializableError>(badRequestObjectResult.Value);
            }
        }
コード例 #2
0
        public async Task SendSignUpMessageAsync_ShouldSend_AndReturnOk()
        {
            var signUpMessageSenderMock = new Mock <ISignUpMessageSender>();
            var userStoreMock           = new Mock <IUserStore <User> >();
            var userManagerMock         = new Mock <UserManager <User> >(userStoreMock.Object, null, null, null, null, null, null, null, null);

            userManagerMock.Setup(m => m.FindByEmailAsync(It.IsAny <string>())).ReturnsAsync(new User());

            using (var controller = new SignUpController(userManagerMock.Object, null, signUpMessageSenderMock.Object))
            {
                IActionResult actionResult = await controller.SendEmailMessageAsync(new SignUpSendEmailMessageViewModel());

                signUpMessageSenderMock.Verify(m => m.SendAsync(It.IsAny <User>()));
                Assert.IsType <OkResult>(actionResult);
            }
        }
コード例 #3
0
        public async Task SendSignUpMessageAsync_ShouldReturnBadRequest_WithModelState_WhenEmailAlreadyConfirmed()
        {
            var signUpMessageSenderMock = new Mock <ISignUpMessageSender>();
            var userStoreMock           = new Mock <IUserStore <User> >();
            var userManagerMock         = new Mock <UserManager <User> >(userStoreMock.Object, null, null, null, null, null, null, null, null);

            userManagerMock.Setup(m => m.FindByEmailAsync(It.IsAny <string>())).ReturnsAsync(new User {
                EmailConfirmed = true
            });

            using (var controller = new SignUpController(userManagerMock.Object, null, signUpMessageSenderMock.Object))
            {
                IActionResult actionResult = await controller.SendEmailMessageAsync(new SignUpSendEmailMessageViewModel());

                var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(actionResult);
                Assert.IsType <SerializableError>(badRequestObjectResult.Value);
            }
        }