public async Task AndTheApprenticeIsNotBeingStoppedThenTheEventIsPublishedWithTheStopDateSetToTheApprenticeshipsStopDate()
        {
            Apprenticeship.PaymentStatus = Domain.Entities.PaymentStatus.Paused;
            var effectiveFrom    = DateTime.Now.AddDays(-1);                                // the date we don't want
            var expectedStopDate = Apprenticeship.StopDate = DateTime.Now.AddMonths(-1);    // the date we want

            await Service.PublishEvent(Commitment, Apprenticeship, _event, effectiveFrom);

            CommitmentsLogger.Verify(x => x.Info($"Create apprenticeship event: {_event}", null, null, Commitment.Id, Apprenticeship.Id, null, null), Times.Once);
            EventsApi.Verify(x => x.CreateApprenticeshipEvent(It.Is <ApprenticeshipEvent>(e => e.StoppedOnDate == expectedStopDate)), Times.Once);
        }
 public void VerifyExceptionIsLogged <TException>() where TException : Exception
 {
     CommitmentsLogger.Verify(x => x.Error(It.Is <Exception>(e => e.GetType() == typeof(TException)), It.Is <string>(s => s.EndsWith("failed")), null, null, null, null, null));
 }
 private void VerifyEventWasPublished(string @event, DateTime?effectiveFrom = null)
 {
     CommitmentsLogger.Verify(x => x.Info($"Create apprenticeship event: {@event}", null, null, Commitment.Id, Apprenticeship.Id, null, null), Times.Once);
     EventsApi.Verify(x => x.CreateApprenticeshipEvent(It.Is <ApprenticeshipEvent>(y => EventMatchesParameters(y, @event, effectiveFrom))), Times.Once);
 }
 private void VerifyEventWasPublished(string @event)
 {
     CommitmentsLogger.Verify(x => x.Info("Creating apprenticeship events", null, null, null, null, null, null), Times.Once);
     EventsApi.Verify(x => x.BulkCreateApprenticeshipEvent(It.Is <List <ApprenticeshipEvent> >(y => y.TrueForAll(z => EventMatchesParameters(z, @event)))), Times.Once);
 }