public async Task JobProfileServiceGetAllListReturnsSuccess() { // arrange var expectedResults = A.CollectionOfFake <JobProfileModel>(2); A.CallTo(() => repository.GetAllAsync()).Returns(expectedResults); // act var results = await jobProfileService.GetAllAsync().ConfigureAwait(false); // assert A.CallTo(() => repository.GetAllAsync()).MustHaveHappenedOnceExactly(); A.Equals(results, expectedResults); }
public async Task <ContentResult> Sitemap() { try { logService.LogInformation("Generating Sitemap"); var sitemapUrlPrefix = $"{Request.GetBaseAddress()}{ProfileController.ProfilePathRoot}"; var sitemap = new Sitemap(); var jobProfileModels = await jobProfileService.GetAllAsync().ConfigureAwait(false); if (jobProfileModels != null) { var jobProfileModelsList = jobProfileModels.ToList(); if (jobProfileModelsList.Any()) { var sitemapJobProfileModels = jobProfileModelsList .Where(w => w.IncludeInSitemap) .OrderBy(o => o.CanonicalName); foreach (var jobProfileModel in sitemapJobProfileModels) { sitemap.Add(new SitemapLocation { Url = $"{sitemapUrlPrefix}/{jobProfileModel.CanonicalName}", Priority = 1, }); } } } // extract the sitemap var xmlString = sitemap.WriteSitemapToString(); logService.LogInformation("Generated Sitemap"); return(Content(xmlString, MediaTypeNames.Application.Xml)); } catch (Exception ex) { logService.LogError($"{nameof(Sitemap)}: {ex.Message}"); } return(null); }
public async Task <IActionResult> Index() { //AOP: These should be coded as an Aspect logService.LogInformation($"{nameof(Index)} has been called"); var viewModel = new IndexViewModel(); var jobProfileModels = await jobProfileService.GetAllAsync().ConfigureAwait(false); if (jobProfileModels is null) { logService.LogWarning($"{nameof(Index)} has returned with no results"); } else { viewModel.Documents = (from a in jobProfileModels.OrderBy(o => o.CanonicalName) select mapper.Map <IndexDocumentViewModel>(a)).ToList(); logService.LogInformation($"{nameof(Index)} has succeeded"); } return(this.NegotiateContentResult(viewModel)); }