public void GetDeparturesByDateShouldThrowExceptionWithNoDepartures() { Mock <DbSet <Voucher> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Vouchers).Returns(mockSet.Object); var service = new VoucherService(mockContext.Object); DateTime departuresDate = new DateTime(2019, 01, 31); Assert.Throws <InvalidOperationException>(() => service.GetDeparturesByDate(departuresDate)); }
public void GetDeparturesByDateShouldReturnAllDeparturesOnExactDate() { Mock <DbSet <Voucher> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Vouchers).Returns(mockSet.Object); var service = new VoucherService(mockContext.Object); DateTime arrivingDate = new DateTime(2019, 08, 13); var departures = service.GetDeparturesByDate(arrivingDate); decimal expectedDeparturesCount = 2; Assert.AreEqual(expectedDeparturesCount, departures.Count); }