Beispiel #1
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 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)));
        }
        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)));
        }
        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 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 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));
        }
Beispiel #7
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));
        }
Beispiel #8
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));
        }