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); }
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)); }