public void GetTablesCountShould_ReturnZero_WhenThereIsTableInThisPlace(string placeId, int peopleCount) { var repositoryMock = new Mock <IRepository <Table> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var factoryMock = new Mock <ITablesFactory>(); var service = new Services.TablesService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object); var placeIdGuid = new Guid(placeId); var table = new Table() { PlaceId = placeIdGuid, NumberOfPeople = peopleCount, NumberOfTables = 12 }; var listAll = new List <Table>() { table }; repositoryMock .Setup(r => r.All) .Returns(listAll.AsQueryable <Table>()); var result = service.GetTablesCount(placeIdGuid, peopleCount); Assert.AreEqual(12, result); }
public void GetTablesCountShould_CallRepositoryPropertyAll(string placeId, int peopleCount) { var repositoryMock = new Mock <IRepository <Table> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var factoryMock = new Mock <ITablesFactory>(); var service = new Services.TablesService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object); var placeIdGuid = new Guid(placeId); service.GetTablesCount(placeIdGuid, peopleCount); repositoryMock.Verify(r => r.All, Times.Once); }