public void Given_when_query_client_by_accountNummber_then_returns_the_Additional_Health_and_Safety_Site_Detials_Only() { var sites = new List<SiteAddressResponse> { new SiteAddressResponse { Id = 1, Address1 = "Address 1", Address2 = "Address 2", County = "County", Postcode = "M12 3EB", IsAdditionalHealthAndSafetySite = true }, new SiteAddressResponse { Id = 1, Address1 = "Address 1", Address2 = "Address 2", County = "County", Postcode = "M12 3EB" } }; var additionalHealthAndSafetSitesCount = sites.Count(s => s.IsAdditionalHealthAndSafetySite); _clientDetailService .Setup(cs => cs.GetSites(It.IsAny<int>())) .Returns(sites); //When var target = new ClientController(_dependencyFactory.Object); var result = target.Query("Den101"); Assert.That(result.Sites.Count(), Is.EqualTo(additionalHealthAndSafetSitesCount)); }
public void Given_client_has_active_checklist_for_site_when_query_result_containts_checklist() { var siteId = 1234L; var sites = new List<SiteAddressResponse> { new SiteAddressResponse { Id = siteId, Address1 = "Address 1", Address2 = "Address 2", County = "County", Postcode = "M12 3EB", IsPrincipalHealthAndSafetySite = true } }; var checklistId = Guid.NewGuid(); var checklists = new List<Checklist> { new Checklist { Id = checklistId, SiteId = (int)siteId, Status = Checklist.STATUS_DRAFT } }; _clientDetailService .Setup(cs => cs.GetSites(It.IsAny<int>())) .Returns(sites); _checklistRepository .Setup(x => x.GetByClientId(It.IsAny<long>(), It.IsAny<bool>())) .Returns(checklists); //When var target = new ClientController(_dependencyFactory.Object); var result = target.Query("den101"); //then Assert.That(result.Sites.FirstOrDefault(x => x.Id == siteId).Checklist.Id, Is.EqualTo(checklistId)); }
public void Given_when_query_client_by_accountNummber_then_returns_the_Main_Site_Only() { var sites = new List<SiteAddressResponse> { new SiteAddressResponse { Id = 1, Address1 = "Address 1", Address2 = "Address 2", County = "County", Postcode = "M12 3EB", IsMainSite = true }, new SiteAddressResponse { Id = 1, Address1 = "Address 1", Address2 = "Address 2", County = "County", Postcode = "M12 3EB" } }; var mainSitesCount = sites.Count(s => s.IsMainSite); _clientDetailService .Setup(cs => cs.GetSites(It.IsAny<int>())) .Returns(sites); _checklistRepository .Setup(x => x.GetByClientId(It.IsAny<long>(), It.IsAny<bool>())) .Returns(new List<Checklist>()); //When var target = new ClientController(_dependencyFactory.Object); var result = target.Query("Den101"); Assert.That(result.Sites.Count(), Is.EqualTo(mainSitesCount)); }
public void Given_when_query_client_by_accountNummber_then_returns_Only_Main_and_Health_and_Safety_Sites_Detials() { var sites = GetSitesAddress(); var mainAndHsSitesCount = sites.Count(s => s.IsMainSite || s.IsAdditionalHealthAndSafetySite || s.IsArchivedHealthAndSafetySite || s.IsPrincipalHealthAndSafetySite); _clientDetailService .Setup(cs => cs.GetSites(It.IsAny<int>())) .Returns(sites); _checklistRepository .Setup(x => x.GetByClientId(It.IsAny<long>(), It.IsAny<bool>())) .Returns(new List<Checklist>()); //When var target = new ClientController(_dependencyFactory.Object); var result = target.Query("Den101"); Assert.That(result.Sites.Count, Is.EqualTo(mainAndHsSitesCount)); }