Example #1
0
        public void AuthenticateUserTest_Given_Email_And_Password_Then_True_Should_Be_Returned_If_Password_Match(
            string inputPassword, bool expectedResult)
        {
            //Arrange
            const string passwordSalt = "passwordSalt";

            var    cryptographyService = new CryptographyService();
            string password            = cryptographyService.CreatePasswordHash("password", passwordSalt);

            _cryptographyServiceMock.Setup(service => service.CreatePasswordHash("password", passwordSalt))
            .Returns(password);

            RecipeManagementContext.PrepareTestData(context =>
            {
                context.Users.Add(new User
                {
                    EmailAddress = "*****@*****.**",
                    Password     = password,
                    PasswordSalt = passwordSalt
                });
            });

            //Act
            bool isAuthenticated = _userService.AuthenticateUser("*****@*****.**", inputPassword);

            //Assert
            Assert.That(isAuthenticated, Is.EqualTo(expectedResult));
        }