Esempio n. 1
0
        public void ThrowArgumentException_WhenPasswordParameterIsAnEmptyString()
        {
            // Arrange
            var authSignInManagerProvider = new Mock <IAuthSignInManagerProvider>();
            var authUserManagerProvider   = new Mock <IAuthUserManagerProvider>();

            var identityAuthAccountService = new IdentityAuthAccountService(authSignInManagerProvider.Object, authUserManagerProvider.Object);

            var email      = "any string";
            var password   = string.Empty;
            var rememberMe = true;

            // Act & Assert
            Assert.That(
                async() => await identityAuthAccountService.PasswordSignInAsync(email, password, rememberMe),
                Throws.InstanceOf <ArgumentException>().With.Message.Contains(nameof(password)));
        }
Esempio n. 2
0
        public async Task InvokeIAuthSignInManagerProvider_SignInManagerPropertyPasswordSignInAsyncMethodOnceWithCorrectParameters()
        {
            // Arrange
            var authSignInManagerProvider = new Mock <IAuthSignInManagerProvider>();
            var authUserManagerProvider   = new Mock <IAuthUserManagerProvider>();

            var identityAuthAccountService = new IdentityAuthAccountService(authSignInManagerProvider.Object, authUserManagerProvider.Object);

            var email      = "any string";
            var password   = "******";
            var rememberMe = true;

            var signInManager = new Mock <IAuthSignInManager>();

            authSignInManagerProvider.SetupGet(m => m.SignInManager).Returns(signInManager.Object);

            var shouldLockout = false;

            // Act
            await identityAuthAccountService.PasswordSignInAsync(email, password, rememberMe);

            // Assert
            signInManager.Verify(m => m.PasswordSignInAsync(email, password, rememberMe, shouldLockout), Times.Once);
        }