Exemplo n.º 1
0
        public async Task Setup()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var pageSize = fixture.Create <int>();

            _expectedTotal           = fixture.Create <int>();
            _expectedCurrentPage     = fixture.Create <int>();
            _expectedSortBy          = SortBy.Distance;
            _vacancySearchParameters = new VacancySearchParameters
            {
                PageSize        = pageSize,
                PageNumber      = _expectedCurrentPage,
                SortBy          = _expectedSortBy,
                Latitude        = 32,
                Longitude       = 2,
                DistanceInMiles = 342
            };
            _expectedTotalPages = Math.Ceiling((double)_expectedTotal / pageSize);

            _apprenticeshipResults = fixture.Create <List <ApprenticeshipSearchResult> >();

            _mockSearchClient = fixture.Freeze <Mock <IApprenticeshipSearchClient> >();

            _mockSearchClient.Setup(c => c.Search(It.IsAny <ApprenticeshipSearchRequestParameters>()))
            .Returns((ApprenticeshipSearchRequestParameters r) => new ApprenticeshipSearchResponse(
                         _expectedTotal,
                         _apprenticeshipResults,
                         Enumerable.Empty <AggregationResult>(),
                         r));

            _apprenticeshipSearchService = fixture.Create <ApprenticeshipSearchService>();

            _actualResponse = await _apprenticeshipSearchService.SearchApprenticeshipVacanciesAsync(_vacancySearchParameters);
        }
Exemplo n.º 2
0
        public void AndExceptionThrownBySearchClient_ThenThrowsInfrastructureException()
        {
            _mockSearchClient
            .Setup(client => client.Search(It.IsAny <ApprenticeshipSearchRequestParameters>()))
            .Throws <Exception>();

            var ex = Assert.ThrowsAsync <InfrastructureException>(() => _apprenticeshipSearchService.SearchApprenticeshipVacanciesAsync(new VacancySearchParameters()));

            Assert.That(ex.InnerException, Is.TypeOf <Exception>());
        }