public async Task ThenTheEventsAreCreated()
        {
            await Orchestrator.CreateEvents(_events);

            EventsLogger.Verify(x => x.Info($"Bulk Uploading {_events.Count} Apprenticeship Event", null, null, null));
            Mediator.Verify(m => m.SendAsync(It.Is <BulkUploadCreateApprenticeshipEventsCommand>(x => BulkCommandMatchesEvents(x, _events))), Times.Once);
        }
Пример #2
0
        public async Task ThenTheEventIsCreated()
        {
            var request = new ApiApprenticeshipEventBuilder().Build();
            await Orchestrator.CreateEvent(request);

            EventsLogger.Verify(x => x.Info($"Creating Apprenticeship Event ({request.Event}) for Employer: {request.EmployerAccountId}, Provider: {request.ProviderId}", request.EmployerAccountId, request.ProviderId, request.Event));
            Mediator.Verify(m => m.SendAsync(It.Is <CreateApprenticeshipEventCommand>(x => CommandMatchesRequest(x, request))), Times.Once);
        }
        public async Task ThenTheEventIsCreated()
        {
            var command = new CreateApprenticeshipEventCommandBuilder().Build();

            await Handler.Handle(command);

            EventsLogger.Verify(x => x.Info($"Received message {command.Event}", command.EmployerAccountId, command.ProviderId, command.Event), Times.Once);
            Repository.Verify(x => x.Create(It.Is <ApprenticeshipEvent>(e => EventMatchesCommand(e, command))));
            EventsLogger.Verify(x => x.Info($"Finished processing message {command.Event}", command.EmployerAccountId, command.ProviderId, command.Event), Times.Once);
        }
        public async Task ThenTheEventIsCreated()
        {
            var request = new AccountEvent {
                ResourceUri = "/api/accounts/ABC123", Event = "Test"
            };
            await Orchestrator.CreateEvent(request);

            EventsLogger.Verify(x => x.Info($"Creating Account Event ({request.Event})", request.ResourceUri, null, request.Event));
            Mediator.Verify(m => m.SendAsync(It.Is <CreateAccountEventCommand>(x => x.ResourceUri == request.ResourceUri && x.Event == request.Event)));
        }
Пример #5
0
        public void AndAnExceptionOccursThenTheErrorIsLogged()
        {
            var exception = new Exception("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <GetAccountEventsRequest>())).ThrowsAsync(exception);

            Assert.ThrowsAsync <Exception>(() => Orchestrator.GetEvents(DateTime.Now.AddDays(-30).ToString("yyyyMMddHHmmss"), DateTime.Now.ToString("yyyyMMddHHmmss"), 100, 1, 123));

            EventsLogger.Verify(x => x.Error(exception, exception.Message, null, null, null));
        }
        public async Task ThenTheEventIsCreated()
        {
            var request = new AgreementEvent {
                ContractType = "MainProvider", Event = "Test", ProviderId = "ZZZ999"
            };
            await Orchestrator.CreateEvent(request);

            EventsLogger.Verify(x => x.Info($"Creating Agreement Event ({request.Event}), Contract: {request.ContractType}, Provider: {request.ProviderId}", null, request.ProviderId, request.Event));
            Mediator.Verify(m => m.SendAsync(It.Is <CreateAgreementEventCommand>(x => x.ContractType == request.ContractType && x.Event == request.Event && x.ProviderId == request.ProviderId)));
        }
Пример #7
0
        public void AndValidationFails()
        {
            var validationException = new ValidationException("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <GetAccountEventsRequest>())).ThrowsAsync(validationException);

            Assert.ThrowsAsync <ValidationException>(() => Orchestrator.GetEvents(DateTime.Now.AddDays(-30).ToString("yyyyMMddHHmmss"), DateTime.Now.ToString("yyyyMMddHHmmss"), 100, 1, 123));

            EventsLogger.Verify(x => x.Warn(validationException, "Invalid request", null, null, null));
        }
        public void AndValidationFailsThenTheFailureIsLogged()
        {
            var validationException = new ValidationException("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <BulkUploadCreateApprenticeshipEventsCommand>())).ThrowsAsync(validationException);

            Assert.ThrowsAsync <ValidationException>(() => Orchestrator.CreateEvents(_events));

            EventsLogger.Verify(x => x.Warn(validationException, "Invalid apprenticeship event bulk upload request", null, null, null));
        }
        public void AndAnExceptionOccursThenTheErrorIsLogged()
        {
            var exception = new Exception("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <BulkUploadCreateApprenticeshipEventsCommand>())).ThrowsAsync(exception);

            Assert.ThrowsAsync <Exception>(() => Orchestrator.CreateEvents(_events));

            EventsLogger.Verify(x => x.Error(exception, exception.Message, null, null, null));
        }
        public void AndValidationFailsThenTheFailureIsLogged()
        {
            var request             = new AgreementEvent();
            var validationException = new ValidationException("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <CreateAgreementEventCommand>())).ThrowsAsync(validationException);

            Assert.ThrowsAsync <ValidationException>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Warn(validationException, "Invalid request", request.ContractType, request.ProviderId, request.Event));
        }
        public void AndValidationFailsThenTheFailureIsLogged()
        {
            var request             = new AccountEvent();
            var validationException = new ValidationException("Exception");

            Mediator.Setup(m => m.SendAsync(It.Is <CreateAccountEventCommand>(x => x.ResourceUri == request.ResourceUri && x.Event == request.Event))).ThrowsAsync(validationException);

            Assert.ThrowsAsync <ValidationException>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Warn(validationException, "Invalid request", request.ResourceUri, null, request.Event));
        }
        public void AndAnExceptionOccursThenTheErrorIsLogged()
        {
            var request   = new AccountEvent();
            var exception = new Exception("Exception");

            Mediator.Setup(m => m.SendAsync(It.Is <CreateAccountEventCommand>(x => x.ResourceUri == request.ResourceUri && x.Event == request.Event))).ThrowsAsync(exception);

            Assert.ThrowsAsync <Exception>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Error(exception, exception.Message, null, null, null));
        }
        public void AndTheEventCreationFailsThenTheExceptionIsLogged()
        {
            var command           = new CreateApprenticeshipEventCommandBuilder().Build();
            var expectedException = new Exception("Test");

            Repository.Setup(x => x.Create(It.Is <ApprenticeshipEvent>(e => EventMatchesCommand(e, command)))).Throws(expectedException);

            Assert.ThrowsAsync <Exception>(() => Handler.Handle(command));

            EventsLogger.Verify(x => x.Error(expectedException, $"Error processing message {command.Event} - {expectedException.Message}", command.EmployerAccountId, command.ProviderId, command.Event), Times.Once);
        }
        public async Task ThenTheEventIsCreated()
        {
            var command = new CreateAgreementEventCommand {
                ContractType = "MainProvider", Event = "Some Event", ProviderId = "ZZZ999"
            };

            await Handler.Handle(command);

            EventsLogger.Verify(x => x.Info($"Received message {command.Event}", null, command.ProviderId, command.Event), Times.Once);
            Repository.Verify(x => x.Create(It.Is <AgreementEvent>(e => e.ContractType == command.ContractType && e.Event == command.Event && e.ProviderId == command.ProviderId)));
            EventsLogger.Verify(x => x.Info($"Finished processing message {command.Event}", null, null, null), Times.Once);
        }
        public async Task ThenTheEventIsCreated()
        {
            var command = new CreateAccountEventCommand {
                ResourceUri = "/api/accounts/ABC123", Event = "Some Event"
            };

            await Handler.Handle(command);

            EventsLogger.Verify(x => x.Info($"Received message {command.Event}", command.ResourceUri, null, command.Event), Times.Once);
            Repository.Verify(x => x.Create(It.Is <AccountEvent>(e => e.ResourceUri == command.ResourceUri && e.Event == command.Event)));
            EventsLogger.Verify(x => x.Info($"Finished processing message {command.Event}", null, null, null), Times.Once);
        }
        public void AndTheEventCreationFailsThenTheExceptionIsLogged()
        {
            var command = new CreateAgreementEventCommand {
                ContractType = "MainProvider", Event = "Some Event", ProviderId = "ZZZ999"
            };
            var expectedException = new Exception("Test");

            Repository.Setup(x => x.Create(It.Is <AgreementEvent>(e => e.ContractType == command.ContractType && e.Event == command.Event && e.ProviderId == command.ProviderId))).Throws(expectedException);

            Assert.ThrowsAsync <Exception>(() => Handler.Handle(command));

            EventsLogger.Verify(x => x.Error(expectedException, $"Error processing message {command.Event} - {expectedException.Message}", null, command.ProviderId, command.Event), Times.Once);
        }
        public void AndTheEventCreationFailsThenTheExceptionIsLogged()
        {
            var command = new CreateAccountEventCommand {
                ResourceUri = "/api/accounts/ABC123", Event = "Some Event"
            };
            var expectedException = new Exception("Test");

            Repository.Setup(x => x.Create(It.Is <AccountEvent>(e => e.ResourceUri == command.ResourceUri && e.Event == command.Event))).Throws(expectedException);

            Assert.ThrowsAsync <Exception>(() => Handler.Handle(command));

            EventsLogger.Verify(x => x.Error(expectedException, $"Error processing message {command.Event} - {expectedException.Message}", command.ResourceUri, null, command.Event), Times.Once);
        }
        public void AndTheEventCreationFailsThenTheExceptionIsLogged()
        {
            var command = new CreateGenericEventCommand {
                Payload = "dfljihldfkmgfdg", Type = "EventType"
            };
            var expectedException = new Exception("Test");

            Repository.Setup(x => x.Create(It.Is <GenericEvent>(e => e.Payload == command.Payload && e.Type == command.Type))).Throws(expectedException);

            Assert.ThrowsAsync <Exception>(() => Handler.Handle(command));

            EventsLogger.Verify(x => x.Error(expectedException, "Error storing generic event in database", null, null, null), Times.Once);
        }
Пример #19
0
        public void AndAnExceptionOccursThenTheErrorIsLogged()
        {
            var request = new ApprenticeshipEvent {
                PriceHistory = new List <PriceHistory>()
            };
            var exception = new Exception("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <CreateApprenticeshipEventCommand>())).ThrowsAsync(exception);

            Assert.ThrowsAsync <Exception>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Error(exception, exception.Message, null, null, null));
        }
Пример #20
0
        public void AndValidationFailsThenTheFailureIsLogged()
        {
            var request = new ApprenticeshipEvent {
                PriceHistory = new List <PriceHistory>()
            };
            var validationException = new ValidationException("Exception");

            Mediator.Setup(m => m.SendAsync(It.IsAny <CreateApprenticeshipEventCommand>())).ThrowsAsync(validationException);

            Assert.ThrowsAsync <ValidationException>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Warn(validationException, "Invalid request", request.EmployerAccountId, request.ProviderId, request.Event));
        }
        public async Task ThenTheEventIsCreated()
        {
            var command = new CreateGenericEventCommand {
                Payload = "dfljihldfkmgfdg", Type = "EventType", ResourceId = "Id", ResourceType = "Type"
            };

            await Handler.Handle(command);

            EventsLogger.Verify(x => x.Info($"Creating Generic Event of type {command.Type}", null, null, null), Times.Once);
            Repository.Verify(
                x =>
                x.Create(
                    It.Is <GenericEvent>(
                        e =>
                        e.Payload == command.Payload && e.Type == command.Type && e.ResourceId == command.ResourceId &&
                        e.ResourceType == command.ResourceType)));
        }