Exemple #1
0
        public Task SkipToDate(DateTime date, bool throws = true)
        {
            if (date < _dateService.GetNow())
            {
                throw new ArgumentException("Cannot go backwards through time.");
            }

            _dateService.SetNow(date);

            return(TickTo(date, throws));
        }
        public async Task Advance_To_Date_Less_Than_Now_Should_Throw()
        {
            //Arrange
            var date = new DateTime(2017, 1, 2, 3, 4, 5);
            var now  = new DateTime(2017, 1, 2, 3, 4, 6);

            _dateSimulationService.GetNow().Returns(now);


            //Act
            var ex = await Assert.ThrowsAsync <ArgumentException>(() => _engine.AdvanceToDateAsync(date));

            //Assert
            Assert.Equal("Cannot run to a date prior to what is currently now in the date simulation service.", ex.Message);
        }
Exemple #3
0
        public async Task Send_Emails()
        {
            var eninge = new TestingBatchEngine(_store, _dateSimulationService, _dependencyResolver);

            var emails = new List <string>
            {
                "*****@*****.**",
                "*****@*****.**"
            };

            //Call some method that schedules work
            await _emailScheduler.SendEmailsAsync(emails);

            //Should not have received any calls
            _emailSender.DidNotReceive().SendEmail(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());

            //Simulate that 8 hours has passed
            await eninge.AdvanceToDateAsync(_dateSimulationService.GetNow().AddHours(8));

            //Assert that emails have been sent
            _emailSender.Received(1).SendEmail("*****@*****.**", "*****@*****.**", "Hello world!");
            _emailSender.Received(1).SendEmail("*****@*****.**", "*****@*****.**", "Hello world!");
        }