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); }
protected static BO.Taxonomy.BOTaxon CustomConditionGetTaxonHavingUsage(BO.Taxonomy.BOTaxon Taxon, object[] Taxa) { BO.Taxonomy.BOUsage [] Usages = Taxon.GetUsage(); if (Usages.Length > 0) { return(Taxon); } else { return(null); } }