public void ReturnNull_WhenThereIsNotAModelWithThePassedUser() { // Arrange var mockedEfWrappert = new Mock <IEfDbSetWrapper <Individual> >(); var mockedDbContext = new Mock <IUnitOfWork>(); string username = "******"; var user = new User(); user.UserName = username; var individual = new Individual(); individual.User = user; var data = new List <Individual>(); data.Add(individual); mockedEfWrappert.SetupGet(m => m.All).Returns(data.AsQueryable()); var service = new IndividualService(mockedEfWrappert.Object, mockedDbContext.Object); // Act var result = service.GetByUsername("otherTestUser"); // Assert Assert.IsNull(result); }
public void NotThrowException_WhenUserIsNull() { // Arange var mockedEfWrappert = new Mock <IEfDbSetWrapper <Individual> >(); var mockedDbContext = new Mock <IUnitOfWork>(); var service = new IndividualService(mockedEfWrappert.Object, mockedDbContext.Object); // Act & Assert Assert.DoesNotThrow(() => service.GetByUsername(null)); }