Пример #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 user     = new AuthUser();
            var password = string.Empty;

            // Act & Assert
            Assert.That(
                async() => await identityAuthAccountService.CreateAsync(user, password),
                Throws.InstanceOf <ArgumentException>().With.Message.Contains(nameof(password)));
        }
Пример #2
0
        public void ThrowArgumentNullException_WhenAuthUserParameterIsNull()
        {
            // Arrange
            var authSignInManagerProvider = new Mock <IAuthSignInManagerProvider>();
            var authUserManagerProvider   = new Mock <IAuthUserManagerProvider>();

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

            AuthUser user     = null;
            var      password = "******";

            // Act & Assert
            Assert.That(
                async() => await identityAuthAccountService.CreateAsync(user, password),
                Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(AuthUser)));
        }
Пример #3
0
        public async Task InvokeIAuthUserManagerProvider_UserManagerPropertyCreateAsyncMethodOnceWithCorrectParameters()
        {
            // Arrange
            var authSignInManagerProvider = new Mock <IAuthSignInManagerProvider>();
            var authUserManagerProvider   = new Mock <IAuthUserManagerProvider>();

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

            var user     = new AuthUser();
            var password = "******";

            var userManager = new Mock <IAuthUserManager>();

            authUserManagerProvider.SetupGet(p => p.UserManager).Returns(userManager.Object);

            // Act
            await identityAuthAccountService.CreateAsync(user, password);

            // Assert
            userManager.Verify(m => m.CreateAsync(user, password), Times.Once);
        }