public async Task should_signin_user_and_redirect_when_signin_with_valid_user()
        {
            // Arrange
            ClaimsPrincipal signedInClaimsPrincipal = null;
            var             authService             = new Mock <IAuthenticationService>();

            authService.Setup(auth => auth.SignInAsync(It.IsAny <HttpContext>(), It.IsAny <string>(), It.IsAny <ClaimsPrincipal>(), It.IsAny <AuthenticationProperties>()))
            .Returns(Task.CompletedTask)
            .Callback((HttpContext ctx, string scheme, ClaimsPrincipal claimsPrincipal, AuthenticationProperties props) =>
            {
                signedInClaimsPrincipal = claimsPrincipal;
            })
            .Verifiable();
            ReplacableServiceProvider.Replace(services =>
            {
                services.AddSingleton(authService.Object);
            });

            var accountCtrl = _myApp.CreateController <AccountController>();
            var userManager = _myApp.GetService <UserManager <User> >();
            var userRepo    = _myApp.GetService <IRepository <User> >();

            const string password = "******";
            await userManager.CreateAsync(new User
            {
                UserName     = "******",
                DisplayName  = "Jim Green",
                CreatedAtUtc = DateTime.UtcNow
            }, password);


            // Act
            var userModel = new SigninUserViewModel
            {
                UserName = "******",
                Password = password
            };
            var sigininResult = await accountCtrl.DoSignin(userModel, null);

            // Assert
            Assert.True(accountCtrl.ModelState.IsValid);
            sigininResult.IsType <RedirectResult>();

            authService.Verify();
            Assert.Equal("jim", signedInClaimsPrincipal.ToDiscussionUser(userRepo).UserName);
        }
        public async Task should_signout()
        {
            var authService = new Mock <IAuthenticationService>();

            authService.Setup(auth => auth.SignOutAsync(It.IsAny <HttpContext>(), It.IsAny <string>(), It.IsAny <AuthenticationProperties>())).Returns(Task.CompletedTask).Verifiable();
            ReplacableServiceProvider.Replace(services =>
            {
                services.AddSingleton(authService.Object);
            });
            _myApp.MockUser();
            var accountCtrl = _myApp.CreateController <AccountController>();

            var signoutResult = await accountCtrl.DoSignOut();

            Assert.NotNull(signoutResult);
            signoutResult.IsType <RedirectResult>();
            authService.Verify();
        }