示例#1
0
        public void GetByUserIdReturnsAValidUser()
        {
            var mock     = new Mock <IUserRepository>();
            var id       = 1;
            var username = "******";
            var password = "******";

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

            var service = new UsersLogic(mock.Object);
            var sut     = service.GetById(id);

            Assert.Equal(sut.Id, id);
            Assert.Equal(sut.Username, username);
        }
示例#2
0
        public void IdThatIsNotFoundThrowsARecordNotFoundException()
        {
            var mock = new Mock <IUserRepository>();

            var id = 1;

            mock.Setup(e => e.GetSingleUser(id)).Returns((UserModel)null);

            var service = new UsersLogic(mock.Object);

            Assert.Throws <RecordNotFoundException>(() => service.GetById(id));
        }