public async System.Threading.Tasks.Task GetAVSumaryPageTestAsync() { var fakeLogger = A.Fake <IApplicationLogger>(); var fakeAPIService = A.Fake <IApprenticeshipVacancyApi>(); var fakeAuditService = A.Fake <IAuditService>(); var pageNumber = 1; var pageSize = 5; var returnDiffrentProvidersOnPage = 1; A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).Returns(FAAAPIDummyResposnes.GetDummyApprenticeshipVacancySummaryResponse(pageNumber, 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 pageSumary = await aVAPIService.GetAVSumaryPageAsync(mapping, 1); pageSumary.CurrentPage.Should().Be(pageNumber); pageSumary.Results.Count().Should().Be(pageSize); A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).MustHaveHappened(); //check null exception Func <Task> f = async() => { await aVAPIService.GetAVSumaryPageAsync(null, 1); }; f.Should().Throw <ArgumentNullException>(); }
public async Task GetAVSumaryPageAsync(string socCode, string standard, string framework) { var fakeAPIService = A.Fake <IApprenticeshipVacancyApi>(); var fakeLogger = A.Fake <IApplicationLogger>(); var pageNumber = 1; A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)); var aVapiService = new AVAPIService(fakeAPIService, fakeLogger); var mapping = new SocMapping { SocCode = socCode, SocMappingId = Guid.NewGuid(), Standards = new[] { standard }, Frameworks = new[] { framework } }; var result = await aVapiService.GetAVSumaryPageAsync(mapping, pageNumber); if (!mapping.Standards.Where(s => !string.IsNullOrEmpty(s)).Distinct().Any() && !mapping.Frameworks.Where(f => !string.IsNullOrEmpty(f)).Distinct().Any()) { result.Should().BeNull(); } else { A.CallTo(() => fakeAPIService.GetAsync(A <string> ._, RequestType.search)).MustHaveHappened(); } }
public void GetAVSumaryPageAsyncNullExceptionsTest() { //Setup var aVAPIService = new AVAPIService(fakeApprenticeshipVacancyApi, fakeLogger, aVAPIServiceSettings); //Asserts Func <Task> f = async() => { await aVAPIService.GetAVSumaryPageAsync(null, 1).ConfigureAwait(false); }; f.Should().Throw <ArgumentNullException>(); }
public async Task GetAVSumaryPageTestAsync() { //arrange var pageNumber = 1; var pageSize = 5; var returnDiffrentProvidersOnPage = 1; A.CallTo(() => fakeApprenticeshipVacancyApi.GetAsync(A <string> ._, RequestType.Search)).Returns(AVAPIDummyResponses.GetDummyApprenticeshipVacancySummaryResponse(pageNumber, 50, pageSize, pageSize, returnDiffrentProvidersOnPage)); var aVAPIService = new AVAPIService(fakeApprenticeshipVacancyApi, fakeLogger, aVAPIServiceSettings); //Act var pageSumary = await aVAPIService.GetAVSumaryPageAsync(aVMapping, 1).ConfigureAwait(false); //Asserts pageSumary.CurrentPage.Should().Be(pageNumber); pageSumary.Results.Count().Should().Be(pageSize); A.CallTo(() => fakeApprenticeshipVacancyApi.GetAsync(A <string> ._, RequestType.Search)).MustHaveHappened(); }