public async Task ShouldPopulateTraineeshipVacancyUrl()
        {
            //Arrange
            var baseUrl = "https://findapprentice.com/traineeship/reference";

            var mockProvideSettings = new Mock <IProvideSettings>();

            mockProvideSettings
            .Setup(p => p.GetSetting(ApplicationSettingKeys.LiveTraineeshipVacancyBaseUrlKey))
            .Returns(baseUrl);

            var response = new GetTraineeshipVacancyResponse
            {
                TraineeshipVacancy = new Fixture().Build <Domain.Entities.TraineeshipVacancy>()
                                     .With(v => v.VacancyReferenceNumber, VacancyReference)
                                     .Create()
            };

            _mockMediator
            .Setup(m => m.Send(It.IsAny <GetTraineeshipVacancyRequest>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);
            var sut = new GetTraineeshipVacancyOrchestrator(_mockMediator.Object, new TraineeshipMapper(mockProvideSettings.Object), _fixture.Create <IValidationExceptionBuilder>());

            //Act
            var vacancy = await sut.GetTraineeshipVacancyDetailsAsync(VacancyReference.ToString());

            //Assert
            Assert.AreEqual($"{baseUrl}/{VacancyReference}", vacancy.VacancyUrl);
        }
        public async Task WithAnonymousEmployer_ShouldReplaceEmployerNameAndDescription()
        {
            _mockMediator.Setup(m => m.Send(It.IsAny <GetTraineeshipVacancyRequest>(), CancellationToken.None))
            .ReturnsAsync(new GetTraineeshipVacancyResponse
            {
                TraineeshipVacancy = new Fixture().Build <Domain.Entities.TraineeshipVacancy>()
                                     .With(v => v.VacancyReferenceNumber, VacancyReference)
                                     .With(v => v.VacancyStatusId, LiveVacancyStatusId)
                                     .With(v => v.EmployerName, "Her Majesties Secret Service")
                                     .With(v => v.EmployerDescription, "A private description")
                                     .With(v => v.AnonymousEmployerName, "ABC Ltd")
                                     .With(v => v.AnonymousEmployerDescription, "A plain company")
                                     .With(v => v.AnonymousEmployerReason, "Because I want to test")
                                     .Create()
            });

            var sut    = new GetTraineeshipVacancyOrchestrator(_mockMediator.Object, _fixture.Create <TraineeshipMapper>(), _fixture.Create <IValidationExceptionBuilder>());
            var result = await sut.GetTraineeshipVacancyDetailsAsync(VacancyReference.ToString());

            result.VacancyReference.Should().Be(VacancyReference);
            result.EmployerName.Should().Be("ABC Ltd");
            result.EmployerDescription.Should().Be("A plain company");
            result.EmployerWebsite.Should().BeNullOrEmpty();
            result.Location.AddressLine1.Should().BeNull();
            result.Location.AddressLine2.Should().BeNull();
            result.Location.AddressLine3.Should().BeNull();
            result.Location.AddressLine4.Should().BeNull();
            result.Location.AddressLine5.Should().BeNull();
            result.Location.PostCode.Should().BeNull();
            result.Location.GeoPoint.Latitude.Should().BeNull();
            result.Location.GeoPoint.Longitude.Should().BeNull();
            result.Location.Town.Should().NotBeNullOrWhiteSpace();
        }
        public void SetUp()
        {
            _fixture = new Fixture().Customize(new AutoMoqCustomization());

            _expectedErrorMessage = _fixture.Create <string>();

            _mockMediator = _fixture.Freeze <Mock <IMediator> >(composer => composer.Do(mock => mock
                                                                                        .Setup(mediator => mediator.Send(It.IsAny <GetTraineeshipVacancyRequest>(), It.IsAny <CancellationToken>()))
                                                                                        .ReturnsAsync(_fixture.Create <GetTraineeshipVacancyResponse>())));

            _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)
            }))
                                                                                                                            ));

            _sut = _fixture.Create <GetTraineeshipVacancyOrchestrator>();
        }
示例#4
0
 public GetTraineeshipVacancyController(GetTraineeshipVacancyOrchestrator vacancyOrchestrator)
 {
     _vacancyOrchestrator = vacancyOrchestrator;
 }