Example #1
0
        public void GetByUserEmailReturnsAValidUser()
        {
            var mock     = new Mock <IUserRepository>();
            var id       = 1;
            var username = "******";
            var password = "******";
            var email    = "*****@*****.**";

            mock.Setup(e => e.GetSingleUserEmail(email)).Returns(
                new UserModel
            {
                Id           = id,
                PassWord     = password,
                UserName     = username,
                Active       = true,
                Created      = new DateTime(),
                EmailAddress = email,
                Updated      = new DateTime()
            });

            var service = new UsersLogic(mock.Object);
            var sut     = service.GetByEmailAddress(email);

            Assert.Equal(sut.Id, id);
            Assert.Equal(sut.Username, username);
            Assert.Equal(sut.EmailAddress, email);
        }
Example #2
0
        public void EmailThatIsNotFoundThrowsARecordNotFoundException()
        {
            var mock = new Mock <IUserRepository>();

            var emailAddress = "*****@*****.**";

            mock.Setup(e => e.GetSingleUserEmail(emailAddress)).Returns((UserModel)null);

            var service = new UsersLogic(mock.Object);

            Assert.Throws <RecordNotFoundException>(() => service.GetByEmailAddress(emailAddress));
        }