コード例 #1
0
        public void GetArrivalsByDateShouldThrowExceptionWithNoArrivals()
        {
            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, 01, 31);

            Assert.Throws <InvalidOperationException>(() => service.GetArrtivalsByDate(arrivingDate));
        }
コード例 #2
0
        public void GetArrivalsByDateShouldReturnAllArrivalsOnExactDate()
        {
            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, 03);

            var arrivals = service.GetArrtivalsByDate(arrivingDate);

            decimal expectedArrivalsCount = 2;

            Assert.AreEqual(expectedArrivalsCount, arrivals.Count);
        }