/// <summary> /// Saves an animal delegation authority with a new hyperlink /// </summary> /// <param name="authority">the authority to save</param> /// <param name="hyperlink">the new hyperlink</param> protected void SaveWithNewHyperlink(BOAnimalDelegationAuthority authority, string hyperlink) { authority.HyperlinkRTARoadmap = hyperlink; authority.Save(); authority = LoadAnimalDelegationAuthority(); Assert.IsTrue(authority.HyperlinkRTARoadmap == hyperlink); }
public void SaveAnimalDelegationAuthority() { BOAnimalDelegationAuthority authority = LoadAnimalDelegationAuthority(); string originalHyperlink = authority.HyperlinkRTARoadmap; string temporaryHyperlink = "www.unittest.com"; SaveWithNewHyperlink(authority, temporaryHyperlink); SaveWithNewHyperlink(authority, originalHyperlink); }
/// <summary> /// Gets an animal delegation authority given an authority "display" object /// </summary> /// <param name="display">the "display" object</param> /// <returns>the authority</returns> protected BOAnimalDelegationAuthority GetAuthority(BOAnimalDelegationAuthorityDisplay display) { BOAnimalDelegationAuthority authority; int authorityId = display.AnimalDelegationAuthorityID; Assert.IsTrue(authorityId > 0); authority = new BOAnimalDelegationAuthority(authorityId); Assert.IsNotNull(authority); return(authority); }
/// <summary> /// Adds an animal delegation authority to a species. /// </summary> /// <param name="taxon">the species to receive the new authority</param> /// <param name="availableCode">a string containing two ids in the form "ddd,aaa" where ddd is /// the delegation code and aaa is the application type id</param> /// <returns>the animal delegation authority</returns> protected BOAnimalDelegationAuthority AddAnimalDelegationAuthority(BOTaxon taxon, string availableCode) { BOAnimalDelegationAuthority authority = new BOAnimalDelegationAuthority(); string[] parts = availableCode.Split(",".ToCharArray()); authority.DelegationCode = Int32.Parse(parts[0]); authority.ApplicationTypeID = Int32.Parse(parts[1]); authority.SpeciesKingdomID = taxon.KingdomID; authority.SpeciesTaxonomyID = taxon.TaxonId; authority.SpeciesTaxonTypeID = taxon.TaxonTypeID; authority.HyperlinkRTARoadmap = "www.unittest.com"; return((BOAnimalDelegationAuthority)authority.Save()); }
public void DeleteAnimalDelegationAuthority() { foreach (BOTaxon taxon in mSearchResults.Taxa) { // seek the first taxon we can use... ArrayList availableCodes = GetAvailableGuidelineCodes(taxon); if (availableCodes.Count > 0) // found one with room to add { // add, then delete int countBefore = GetDelegationDisplays(taxon).Length; BOAnimalDelegationAuthority authority = AddAnimalDelegationAuthority(taxon, (string)availableCodes[0]); int countAfter = GetDelegationDisplays(taxon).Length; Assert.IsNotNull(authority); Assert.IsTrue(countAfter == countBefore + 1); authority.Delete(); Assert.IsTrue(GetDelegationDisplays(taxon).Length == countBefore); //back to where we were return; } } Assert.Fail("No species found with available guidelines"); }
/// <summary> /// Retrieve a collection of available guideline codes for a particular species /// </summary> /// <param name="taxon">the species</param> /// <returns>a collection of strings containing two ids in the form "ddd,aaa" where ddd is /// the delegation code and aaa is the application type id</returns> public ArrayList GetAvailableGuidelineCodes(BOTaxon taxon) { DelegationGuidelineBoundCollection guidelines = BODelegationGuideline.GetAll(false); BOAnimalDelegationAuthorityDisplay[] displays = GetDelegationDisplays(taxon); ArrayList available = new ArrayList(); Assert.IsNotNull(displays); Assert.IsNotNull(guidelines); foreach (DelegationGuideline guideline in guidelines) // build up array of "x,y" strings { available.Add(guideline.Code.ToString() + "," + guideline.ApplicationTypeCode.ToString()); } foreach (BOAnimalDelegationAuthorityDisplay display in displays) // reduce array as "x,y" strings are found { BOAnimalDelegationAuthority authority = GetAuthority(display); available.Remove(authority.DelegationCode.ToString() + "," + authority.ApplicationTypeID.ToString()); } return(available); // any left? }