예제 #1
0
        public void GetUser_Succeeds()
        {
            // arrange
            var userName = "******";
            var password = "******";

            InsertUser(new User(userName, password));

            // act
            var returnedUser = _sutNoValidation.GetUser(userName);

            // assert
            Assert.AreEqual(userName, returnedUser.UserName);
            Assert.AreEqual(password, returnedUser.Password);
        }
예제 #2
0
        public void GetUser_ThrowsInvalidUserNameException_WhenRepositoryThrowsInvalidUserNameException()
        {
            // arrange
            var exMessage      = "Invalid username";
            var repositoryMock = new Mock <IUserRepository>();

            repositoryMock.Setup(m => m.GetUser(It.IsAny <string>())).Throws(new InvalidUserNameException(exMessage, null));

            var sut = new UserAuthManager(repositoryMock.Object, null);

            // act
            var ex = Assert.ThrowsException <InvalidUserNameException>(() => sut.GetUser("someUserName"));

            // assert
            Assert.AreEqual(exMessage, ex.Message);
        }