Ejemplo n.º 1
0
        public async Task Reset_password()
        {
            string emailAddress = "*****@*****.**";
            //Arrange
            var client = new ClientWrapper(Client, TestMessageServices);
            //Act
            await client.Get("/Account/Login");

            //Assert
            Assert.Contains("/Account/ForgotPassword", client.Html);


            var link = client.GetLink("/Account/ForgotPassword");
            //Act
            await client.Get(link);

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/ForgotPassword"));

            //Act
            await client.Post(1,
                              new ForgotPasswordViewModel
            {
                Email = emailAddress
            });

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/ForgotPassword"));
            Assert.True(client.HasEmail(emailAddress));

            //Act
            await client.ClickOnLinkInEmail(emailAddress);

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/ResetPassword"));

            //Act
            await client.Post(1,
                              new ResetPasswordViewModel
            {
                Email           = emailAddress,
                Password        = "******",
                ConfirmPassword = "******"
            });

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/ResetPasswordConfirmation"));
        }
Ejemplo n.º 2
0
        public async Task Create_User_and_Login()
        {
            //Arrange
            string emailAddress = "*****@*****.**";
            var    client       = new ClientWrapper(Client, TestMessageServices);
            //Act
            await client.Get("/User/Create");

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/Login"));


            //ACT Account/Login
            await client.Post(2,
                              new LoginViewModel
            {
                Email    = "*****@*****.**",
                Password = "******"
            });

            //Assert
            Assert.Equal(null, client.ValidateResponse("/User/Create"));


            //ACT post /User/Create
            await client.Post(1,
                              new ApplicationUser
            {
                UserName          = emailAddress,
                Email             = emailAddress,
                AccessFailedCount = 0,
                EmailConfirmed    = false,
                TwoFactorEnabled  = true
            });

            //Assert
            Assert.Contains("success", client.Html);
            Assert.True(client.HasEmail(emailAddress));


            //ACT get /Account/ConfirmEmail
            await client.ClickOnLinkInEmail(emailAddress);

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/ConfirmEmail"));


            //ACT Post /Account/ConfirmEmail
            await client.Post(1,
                              new ResetPasswordViewModel
            {
                Password        = "******",
                ConfirmPassword = "******",
                RememberMe      = true
            }.AsFormValues()
                              );

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/SendCode"));
            Assert.Equal(null, client.ValidateForm(1,
                                                   new SendCodeViewModel
            {
                RememberMe = true
            }
                                                   ));


            //ACT The post will send an securitycode and redirect to verifycode
            await client.Post(1, new FormValues());

            //Assert
            Assert.Equal(null, client.ValidateResponse("/Account/VerifyCode"));
            Assert.Equal(null, client.ValidateForm(1,
                                                   new VerifyCodeViewModel
            {
                RememberMe      = true,
                RememberBrowser = false
            }
                                                   ));


            //ACT  post verify code
            var code = client.GetSecurityCode(emailAddress);
            await client.Post(1,
                              new VerifyCodeViewModel
            {
                Code            = code,
                RememberBrowser = true
            });

            //Assert
            Assert.Equal(null, client.ValidateResponse("/"));
        }