Beispiel #1
0
        public async Task SetUp()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            _actualParameters = fixture.Create <CreateApprenticeshipParameters>();

            _expectedMediatorResponse = fixture.Create <CreateApprenticeshipResponse>();
            _expectedMapperResponse   = fixture.Create <ApiTypes.CreateApprenticeshipResponse>();
            _expectedRequest          = new CreateApprenticeshipRequest();
            _expectedErrorMessage     = fixture.Create <string>();

            _mockRequestMapper = fixture.Freeze <Mock <ICreateApprenticeshipRequestMapper> >(composer => composer.Do(mock => mock
                                                                                                                     .Setup(mapper => mapper.MapFromApiParameters(_actualParameters, It.IsAny <int>(), It.IsAny <string>()))
                                                                                                                     .Returns(_expectedRequest)));

            _mockMediator = fixture.Freeze <Mock <IMediator> >(composer => composer.Do(mock => mock
                                                                                       .Setup(mediator => mediator.Send(It.IsAny <CreateApprenticeshipRequest>(), It.IsAny <CancellationToken>()))
                                                                                       .ReturnsAsync(_expectedMediatorResponse)));

            _mockResponseMapper = fixture.Freeze <Mock <ICreateApprenticeshipResponseMapper> >(composer => composer.Do(mock => mock
                                                                                                                       .Setup(mapper => mapper.MapToApiResponse(It.IsAny <CreateApprenticeshipResponse>()))
                                                                                                                       .Returns(_expectedMapperResponse)));

            _mockValidationExceptionBuilder = fixture.Freeze <Mock <IValidationExceptionBuilder> >(composer => composer.Do(mock => mock
                                                                                                                           .Setup(builder => builder.Build(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
                                                                                                                           .Returns(new ValidationException(new List <ValidationFailure>
            {
                new ValidationFailure("", _expectedErrorMessage)
            }))
                                                                                                                           ));

            _orchestrator = fixture.Create <CreateApprenticeshipOrchestrator>();

            _actualResponse = await _orchestrator.CreateApprenticeshipAsync(_actualParameters, _validHeader);
        }
Beispiel #2
0
 public CreateApprenticeshipController(CreateApprenticeshipOrchestrator orchestrator)
 {
     _orchestrator = orchestrator;
 }