public FamiliesControllerTests() { var list = new List <Family> { new Family { Id = 1, Name = "test 1", BusinessId = 2 }, new Family { Id = 2, Name = "test 2", BusinessId = 1 } }.AsQueryable(); var mockContext = Substitute.For <TtContext>(); var familyRepository = Substitute.For <Repository <Family> >(mockContext); var businessRepository = Substitute.For <Repository <Business> >(mockContext); _service = Substitute.For <FamilyService>(familyRepository, businessRepository); _service.GetList().Returns(list); _service.GetItem(Arg.Any <int>()).Returns(new Family { Id = 1, Name = "test 1", BusinessId = 1 }); _service.Create(Arg.Any <Family>()); _service.Update(Arg.Any <int>(), Arg.Any <Family>()); _service.Delete(Arg.Any <int>()); var mockLogger = Substitute.For <ILoggerFactory>(); _controller = new FamiliesController(_service, mockLogger); }
public void GetItemTest() { var family = _service.GetItem(1); Assert.Equal(1, family.Id); }