public async System.Threading.Tasks.Task GetAVsForMultipleProvidersAsync(string socCode, Guid socMappingId, string[] standard, string[] framework)
        {
            var fakeLogger     = A.Fake <IApplicationLogger>();
            var fakeAPIService = A.Fake <IApprenticeshipVacancyApi>();
            var pageNumber     = 1;
            var pageSize       = 5;
            var returnDiffrentProvidersOnPage = 2;

            A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponse(pageNumber, 50, pageSize, pageSize, returnDiffrentProvidersOnPage)).Once().
            Then.Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponse((pageNumber + 1), 50, pageSize, pageSize, returnDiffrentProvidersOnPage));

            var aVapiService = new AVAPIService(fakeAPIService, fakeLogger);

            var mapping = new SocMapping
            {
                SocCode      = socCode,
                SocMappingId = socMappingId,
                Standards    = standard,
                Frameworks   = framework
            };

            var aVSumaryList = await aVapiService.GetAVsForMultipleProvidersAsync(mapping);

            if (!mapping.Standards.Where(s => !string.IsNullOrEmpty(s)).Distinct().Any() && !mapping.Frameworks.Where(f => !string.IsNullOrEmpty(f)).Distinct().Any())
            {
                aVSumaryList.Count().Should().BeLessOrEqualTo(0);
            }
            else
            {
                aVSumaryList.Count().Should().BeGreaterThan(pageSize);
                var numberProviders = aVSumaryList.Select(v => v.TrainingProviderName).Distinct().Count();
                numberProviders.Should().BeGreaterThan(1);
                A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).MustHaveHappened(Repeated.Exactly.Twice);
            }
        }
Ejemplo n.º 2
0
        public async System.Threading.Tasks.Task GetAVsForMultipleProvidersTestAsync()
        {
            //Arrange
            var pageNumber = 1;
            var pageSize   = 5;
            var returnDiffrentProvidersOnPage = 2;

            A.CallTo(() => fakeApprenticeshipVacancyApi.GetAsync(A <string> ._, RequestType.Search)).Returns(AVAPIDummyResponses.GetDummyApprenticeshipVacancySummaryResponse(pageNumber, 50, pageSize, pageSize, returnDiffrentProvidersOnPage)).Once().
            Then.Returns(AVAPIDummyResponses.GetDummyApprenticeshipVacancySummaryResponse(pageNumber + 1, 50, pageSize, pageSize, returnDiffrentProvidersOnPage));

            var aVAPIService = new AVAPIService(fakeApprenticeshipVacancyApi, fakeLogger, aVAPIServiceSettings);

            //Act
            var aVSumaryList = await aVAPIService.GetAVsForMultipleProvidersAsync(aVMapping).ConfigureAwait(false);

            //Asserts
            //must have got more then 1 page to get multipe supplier
            aVSumaryList.Count().Should().BeGreaterThan(pageSize);

            var numberProviders = aVSumaryList.Select(v => v.TrainingProviderName).Distinct().Count();

            numberProviders.Should().BeGreaterThan(1);

            A.CallTo(() => fakeApprenticeshipVacancyApi.GetAsync(A <string> ._, RequestType.Search)).MustHaveHappenedTwiceExactly();
        }
Ejemplo n.º 3
0
        public void GetAVsForMultipleProvidersAsyncNullExceptionsTest()
        {
            //Setup
            var aVAPIService = new AVAPIService(fakeApprenticeshipVacancyApi, fakeLogger, aVAPIServiceSettings);

            //Asserts
            Func <Task> f = async() => { await aVAPIService.GetAVsForMultipleProvidersAsync(null).ConfigureAwait(false); };

            f.Should().Throw <ArgumentNullException>();
        }
        public async System.Threading.Tasks.Task GetAVsForMultipleProvidersTestAsync()
        {
            var fakeLogger       = A.Fake <IApplicationLogger>();
            var fakeAPIService   = A.Fake <IApprenticeshipVacancyApi>();
            var fakeAuditService = A.Fake <IAuditService>();
            var pageNumber       = 1;
            var pageSize         = 5;
            var returnDiffrentProvidersOnPage = 2;

            A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponse(pageNumber, 50, pageSize, pageSize, returnDiffrentProvidersOnPage)).Once().
            Then.Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponse((pageNumber + 1), 50, pageSize, pageSize, returnDiffrentProvidersOnPage));

            var client = new ClientProxy(fakeLogger, fakeAuditService);

            var aVAPIService = new AVAPIService(fakeAPIService, fakeLogger);

            var mapping = new SocMapping
            {
                SocCode      = "1234",
                SocMappingId = Guid.NewGuid(),
                Standards    = new string[] { "225" },
                Frameworks   = new string[] { "512" }
            };

            var aVSumaryList = await aVAPIService.GetAVsForMultipleProvidersAsync(mapping);

            //must have got more then 1 page to get multipe supplier
            aVSumaryList.Count().Should().BeGreaterThan(pageSize);

            var numberProviders = aVSumaryList.Select(v => v.TrainingProviderName).Distinct().Count();

            numberProviders.Should().BeGreaterThan(1);

            A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).MustHaveHappened(Repeated.Exactly.Twice);

            //check null exception
            Func <Task> f = async() => { await aVAPIService.GetAVsForMultipleProvidersAsync(null); };

            f.Should().Throw <ArgumentNullException>();
        }
        public async System.Threading.Tasks.Task GetAVsForMultipleProvidersAsyncPageCallTest()
        {
            var fakeLogger     = A.Fake <IApplicationLogger>();
            var fakeAPIService = A.Fake <IApprenticeshipVacancyApi>();
            var pageNumber     = 1;
            var totalPages     = 2;

            A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponseSameProvider(pageNumber, totalPages)).Once().
            Then.Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponseSameProvider((pageNumber + 1), totalPages));

            var aVapiService = new AVAPIService(fakeAPIService, fakeLogger);

            var mapping = new SocMapping
            {
                SocCode      = "DummySOc",
                SocMappingId = new Guid(),
                Standards    = new string[] { "dummy standard" },
                Frameworks   = new string[] { "dummy framework" }
            };

            var aVSumaryList = await aVapiService.GetAVsForMultipleProvidersAsync(mapping);

            A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).MustHaveHappened(totalPages, Times.Exactly);
        }