public void TestSearchForUsage() { //Get a Taxon that has usage details. BO.Taxonomy.BOTaxon AnimalKingdom = BO.Taxonomy.TaxonomySearch.GetAnimalKingdom(); BO.Taxonomy.BOTaxon UsageTaxon = GetTaxonDescendant(AnimalKingdom, BO.Taxonomy.TaxonTypeEnum.Species, new CustomConditionDelegate(CustomConditionGetTaxonHavingUsage)); Assert.IsNotNull(UsageTaxon); BO.Taxonomy.BOUsage TaxonUsage = UsageTaxon.GetUsage() [0]; //Search using usage details to retreive the taxon first thought of. BO.Taxonomy.BOTaxonSearchResults AnimalSearchResults = null; mCommonCriteria.SearchForKingdomType = BO.SearchTaxonomy.SearchKingdomTypeEnum.Animal; mCommonCriteria.SearchForComponentType = BO.SearchTaxonomy.SearchableTaxonomyComponentEnum.Usage; BO.SearchTaxonomy.BOUsageCriteria UsageCriteria = new uk.gov.defra.Phoenix.BO.SearchTaxonomy.BOUsageCriteria(); UsageCriteria.LevelOfUseID = TaxonUsage.LevelID; UsageCriteria.PartID = TaxonUsage.PartID; UsageCriteria.UsageTypeID = TaxonUsage.TypeID; AnimalSearchResults = BO.Taxonomy.TaxonomySearch.SearchUsage(mCommonCriteria, UsageCriteria); Assert.IsTrue(AnimalSearchResults.Taxa.Length > 0); bool UsageTaxonMatchesSearchedTaxon = false; foreach (BO.Taxonomy.BOTaxon FoundTaxon in AnimalSearchResults.Taxa) { UsageTaxonMatchesSearchedTaxon = UsageTaxonMatchesSearchedTaxon | (UsageTaxon.Id == FoundTaxon.Id); } Assert.IsTrue(UsageTaxonMatchesSearchedTaxon); }
public void TestPhylaForDifferentKingdoms() { //Get the phyla belonging to the Animal Kingdom. BO.Taxonomy.BOTaxonSearchResults AnimalSearchResults = null; mCommonCriteria.SearchForKingdomType = BO.SearchTaxonomy.SearchKingdomTypeEnum.Animal; mCommonCriteria.SearchForComponentType = BO.SearchTaxonomy.SearchableTaxonomyComponentEnum.PhylumTaxon; mStringCriteria.SearchString = string.Empty; AnimalSearchResults = BO.Taxonomy.TaxonomySearch.SearchTaxa(mCommonCriteria, mStringCriteria); Assert.GreaterThan(AnimalSearchResults.Taxa.Length, 0); //Get the phyla belonging to the Plant Kingdom. BO.Taxonomy.BOTaxonSearchResults PlantSearchResults = null; mCommonCriteria.SearchForKingdomType = BO.SearchTaxonomy.SearchKingdomTypeEnum.Plant; mCommonCriteria.SearchForComponentType = BO.SearchTaxonomy.SearchableTaxonomyComponentEnum.PhylumTaxon; mStringCriteria.SearchString = string.Empty; PlantSearchResults = BO.Taxonomy.TaxonomySearch.SearchTaxa(mCommonCriteria, mStringCriteria); Assert.GreaterThan(PlantSearchResults.Taxa.Length, 0); //Check that the animal and plant results are different. foreach (BO.Taxonomy.BOTaxon PlantTaxon in PlantSearchResults.Taxa) { Assert.AreNotSame(PlantTaxon.LongScientificNameUnformatted, AnimalSearchResults.Taxa[0].LongScientificNameUnformatted, "The same Phylum appears in more than one Kingdom."); } foreach (BO.Taxonomy.BOTaxon AnimalTaxon in AnimalSearchResults.Taxa) { Assert.AreNotSame(AnimalTaxon.LongScientificNameUnformatted, PlantSearchResults.Taxa[0].LongScientificNameUnformatted, "The same Phylum appears in more than one Kingdom."); } }
public void TestSearchingForSpeciesReturnsSpecies() { BO.Taxonomy.BOTaxon Kingdom = BO.Taxonomy.TaxonomySearch.GetAnimalKingdom(); BO.Taxonomy.BOTaxonSearchResults AnimalSearchResults = null; mCommonCriteria.SearchForKingdomType = BO.SearchTaxonomy.SearchKingdomTypeEnum.Animal; mCommonCriteria.SearchForComponentType = BO.SearchTaxonomy.SearchableTaxonomyComponentEnum.SpeciesTaxon; mStringCriteria.SearchString = "Accipiter"; //Narrow the search results so that there are fewer than the maximum allowed. AnimalSearchResults = BO.Taxonomy.TaxonomySearch.SearchTaxa(mCommonCriteria, mStringCriteria); foreach (BO.Taxonomy.BOTaxon Taxon in AnimalSearchResults.Taxa) { Assert.IsTrue(Taxon.TaxonType == BO.Taxonomy.TaxonTypeEnum.Species | Taxon.TaxonType == BO.Taxonomy.TaxonTypeEnum.Epithet | Taxon.TaxonType == BO.Taxonomy.TaxonTypeEnum.Stock); Assert.IsTrue(Taxon.KingdomID == Kingdom.KingdomID); } }
public void TestKingdomGetChildrenEqualSearchedChildren() { //Get the child taxa. BO.Taxonomy.BOTaxon AnimalKingdom = BO.Taxonomy.TaxonomySearch.GetAnimalKingdom(); BO.Taxonomy.BOTaxon[] LowerTaxa = AnimalKingdom.GetLowerTaxa(); Assert.GreaterThan(LowerTaxa.Length, 1); //Search for the child taxa. BO.Taxonomy.BOTaxonSearchResults SearchResults = null; mCommonCriteria.SearchForKingdomType = BO.SearchTaxonomy.SearchKingdomTypeEnum.Animal; mCommonCriteria.SearchForComponentType = BO.SearchTaxonomy.SearchableTaxonomyComponentEnum.PhylumTaxon; mStringCriteria.SearchString = string.Empty; SearchResults = BO.Taxonomy.TaxonomySearch.SearchTaxa(mCommonCriteria, mStringCriteria); Assert.GreaterThan(SearchResults.Taxa.Length, 1); //Test the 2 sets of results. Assert.AreSame(LowerTaxa.Length, SearchResults.Taxa.Length, "The get results are different to the search results"); for (System.Int32 x = 0; x < LowerTaxa.Length; x++) { Assert.AreSame(LowerTaxa[x].LongScientificNameUnformatted, SearchResults.Taxa[x].LongScientificNameUnformatted, "The get results are different to the search results"); } }