/// <summary> /// Create a TaxonSearchCriteria instance. /// </summary> public TaxonSearchCriteria() { _restrictReturnToScope = WebService.TaxonSearchScope.NoScope; _restrictReturnToTaxonTypeIds = null; _restrictReturnToSwedishSpecies = false; _restrictSearchToSwedishSpecies = false; _restrictSearchToTaxonIds = null; _restrictSearchToTaxonTypeIds = null; _taxonInformationType = TaxonInformationType.Basic; _taxonNameSearchString = null; }
public void GetTaxaBySearchCriteria() { Data.ArtDatabankenService.TaxonList taxa; Data.ArtDatabankenService.TaxonSearchCriteria searchCriteria; foreach (TaxonInformationType taxonInformationType in Enum.GetValues(typeof(TaxonInformationType))) { for (WebService.TaxonSearchScope taxonReturnScope = WebService.TaxonSearchScope.NoScope; taxonReturnScope <= WebService.TaxonSearchScope.AllChildTaxa; taxonReturnScope++) { searchCriteria = new Data.ArtDatabankenService.TaxonSearchCriteria(); searchCriteria.TaxonInformationType = taxonInformationType; searchCriteria.RestrictReturnToScope = taxonReturnScope; searchCriteria.RestrictSearchToTaxonIds = null; searchCriteria.RestrictSearchToTaxonTypeIds = null; searchCriteria.TaxonNameSearchString = null; searchCriteria.RestrictSearchToSwedishSpecies = false; taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); if (taxonReturnScope == WebService.TaxonSearchScope.NoScope) { Assert.IsTrue(taxa.IsNotEmpty()); } else { Assert.IsTrue(taxa.IsEmpty()); } searchCriteria.RestrictSearchToTaxonIds = null; searchCriteria.RestrictSearchToTaxonTypeIds = null; searchCriteria.TaxonNameSearchString = "björn"; searchCriteria.RestrictSearchToSwedishSpecies = true; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsNotNull(taxa); Assert.IsTrue(taxa.IsNotEmpty()); Assert.AreEqual(taxa.Count, 1); searchCriteria.RestrictSearchToTaxonIds = null; searchCriteria.RestrictSearchToTaxonTypeIds = null; searchCriteria.TaxonNameSearchString = "björn%"; searchCriteria.RestrictSearchToSwedishSpecies = false; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsNotNull(taxa); Assert.IsTrue(taxa.IsNotEmpty()); Assert.IsTrue(taxa.Count > 1); searchCriteria.RestrictSearchToTaxonIds = GetTaxaIds(); searchCriteria.RestrictSearchToTaxonTypeIds = null; searchCriteria.TaxonNameSearchString = "björn%"; searchCriteria.RestrictSearchToSwedishSpecies = true; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsNotNull(taxa); Assert.IsTrue(taxa.IsNotEmpty()); Assert.AreEqual(taxa.Count, 1); searchCriteria.RestrictSearchToTaxonIds = GetTaxaIds(); searchCriteria.RestrictSearchToTaxonTypeIds = GetTaxonTypeIds(); searchCriteria.TaxonNameSearchString = "björn%"; searchCriteria.RestrictSearchToSwedishSpecies = false; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsNotNull(taxa); Assert.IsTrue(taxa.IsNotEmpty()); Assert.AreEqual(taxa.Count, 1); searchCriteria.RestrictSearchToTaxonIds = null; searchCriteria.RestrictSearchToTaxonTypeIds = GetTaxonTypeIds(); searchCriteria.TaxonNameSearchString = "%björn%"; searchCriteria.RestrictSearchToSwedishSpecies = true; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsNotNull(taxa); Assert.IsTrue(taxa.IsNotEmpty()); Assert.IsTrue(taxa.Count > 1); searchCriteria.RestrictSearchToTaxonIds = null; searchCriteria.RestrictSearchToTaxonTypeIds = null; searchCriteria.TaxonNameSearchString = "blåvingad sandgräshoppa"; searchCriteria.RestrictReturnToSwedishSpecies = true; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsTrue(taxa.IsEmpty()); } } // Test getting parent taxa. searchCriteria = new ArtDatabanken.Data.ArtDatabankenService.TaxonSearchCriteria(); searchCriteria.TaxonInformationType = TaxonInformationType.Basic; searchCriteria.RestrictReturnToScope = WebService.TaxonSearchScope.AllParentTaxa; searchCriteria.TaxonNameSearchString = "björn"; taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaBySearchCriteria(searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); }