Esempio n. 1
0
        public void GetTaxaBySpeciesObservations()
        {
            Int32           taxonCount;
            List <WebTaxon> taxa;
            WebSpeciesObservationSearchCriteria searchCriteria;

            searchCriteria            = new WebSpeciesObservationSearchCriteria();
            searchCriteria.TaxonIds   = TaxonManagerTest.GetSomeTaxonIds(1);
            searchCriteria.UserRoleId = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            searchCriteria.Accuracy   = 1000;
            taxa = SpeciesObservationManager.GetTaxaBySpeciesObservations(GetContext(), searchCriteria);
            Assert.IsTrue(taxa.IsNotEmpty());

            // Test problem where taxon is of a higher level in
            // the taxon tree.
            searchCriteria = new WebSpeciesObservationSearchCriteria();
            searchCriteria.TaxonIds.Add(MAMMAL_TAXON_ID);
            searchCriteria.UserRoleId = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            taxa       = SpeciesObservationManager.GetTaxaBySpeciesObservations(GetContext(), searchCriteria);
            taxonCount = SpeciesObservationManager.GetTaxaCountBySpeciesObservations(GetContext(), searchCriteria);
            Assert.IsTrue(taxa.IsNotEmpty());
            Assert.AreEqual(taxonCount, taxa.Count);

            // Test observer search string.
            searchCriteria             = new WebSpeciesObservationSearchCriteria();
            searchCriteria.UserRoleId  = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            searchCriteria.DatabaseIds = new List <Int32>();
            searchCriteria.DatabaseIds.Add(7);
            searchCriteria.ObserverSearchString = "";
            taxa       = SpeciesObservationManager.GetTaxaBySpeciesObservations(GetContext(), searchCriteria);
            taxonCount = SpeciesObservationManager.GetTaxaCountBySpeciesObservations(GetContext(), searchCriteria);
            Assert.IsTrue(taxa.IsNotEmpty());
            Assert.AreEqual(taxonCount, taxa.Count);
        }
Esempio n. 2
0
        public void RestrictTaxonTypes()
        {
            List <Int32> taxonTypeIds;

            taxonTypeIds = TaxonManagerTest.GetTaxonTypeIds();
            GetTaxonTreeNode(true).RestrictTaxonTypes(taxonTypeIds);
        }
Esempio n. 3
0
 public WebTaxon GetTaxon()
 {
     if (_taxon.IsNull())
     {
         _taxon = TaxonManagerTest.GetOneTaxon(GetContext());
     }
     return(_taxon);
 }
Esempio n. 4
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        public WebTaxonNameUseType GetTaxonNameUseType()
        {
            if (_taxonNameUseType.IsNull())
            {
                _taxonNameUseType = TaxonManagerTest.GetTaxonNameUseType(GetContext());
            }
            return(_taxonNameUseType);
        }
Esempio n. 5
0
 private WebTaxon GetData(Boolean refresh)
 {
     if (_data.IsNull() || refresh)
     {
         _data = TaxonManagerTest.GetOneTaxon(GetContext());
     }
     return(_data);
 }
 public void DeleteUserSelectedHosts()
 {
     foreach (UserSelectedTaxonUsage hostUsage in Enum.GetValues(typeof(UserSelectedTaxonUsage)))
     {
         SpeciesFactManager.AddUserSelectedHosts(GetContext(), TaxonManagerTest.GetSomeTaxonIds(), hostUsage);
         SpeciesFactManager.DeleteUserSelectedHosts(GetContext());
     }
 }
        public static List <WebSpeciesFact> GetSomeSpeciesFacts(WebServiceContext context)
        {
            WebUserParameterSelection userParameterSelection;

            userParameterSelection          = new WebUserParameterSelection();
            userParameterSelection.TaxonIds = TaxonManagerTest.GetSomeTaxonIds();
            return(SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(context, userParameterSelection));
        }
Esempio n. 8
0
 public WebTaxonTreeNode GetTaxonTreeNode(Boolean refresh)
 {
     if (_taxonTreeNode.IsNull() || refresh)
     {
         _taxonTreeNode = TaxonManagerTest.GetBearTaxonTreeNode(GetContext());
     }
     return(_taxonTreeNode);
 }
Esempio n. 9
0
        public static WebSpeciesObservationInformation GetOneSpeciesObservationInformation(WebServiceContext context)
        {
            WebSpeciesObservationSearchCriteria searchCriteria;

            searchCriteria            = new WebSpeciesObservationSearchCriteria();
            searchCriteria.TaxonIds   = TaxonManagerTest.GetSomeTaxonIds(1);
            searchCriteria.UserRoleId = WebServiceData.UserManager.GetRoles(context)[0].Id;
            searchCriteria.Accuracy   = 1000;
            return(SpeciesObservationManager.GetSpeciesObservations(context, searchCriteria));
        }
Esempio n. 10
0
        public static List <WebSpeciesObservation> GetSomeSpeciesObservations(WebServiceContext context)
        {
            WebSpeciesObservationSearchCriteria searchCriteria;
            WebSpeciesObservationInformation    speciesObservationInformation;

            searchCriteria                = new WebSpeciesObservationSearchCriteria();
            searchCriteria.TaxonIds       = TaxonManagerTest.GetSomeTaxonIds(4);
            searchCriteria.UserRoleId     = WebServiceData.UserManager.GetRoles(context)[0].Id;
            searchCriteria.Accuracy       = 1000;
            speciesObservationInformation = SpeciesObservationManager.GetSpeciesObservations(context, searchCriteria);
            return(speciesObservationInformation.SpeciesObservations);
        }
Esempio n. 11
0
        public void Taxon()
        {
            WebTaxon taxon;

            taxon = null;
            GetTaxonTreeNode(true).Taxon = taxon;
            Assert.IsNull(GetTaxonTreeNode().Taxon);

            taxon = TaxonManagerTest.GetOneTaxon(GetContext());
            GetTaxonTreeNode().Taxon = taxon;
            Assert.IsNotNull(GetTaxonTreeNode().Taxon);
            Assert.AreEqual(GetTaxonTreeNode().Taxon, taxon);
        }
Esempio n. 12
0
        public void GetSpeciesObservationCountBySearchCriteria()
        {
            Int32 speciesObservationCount;
            WebSpeciesObservationSearchCriteria searchCriteria;

            searchCriteria            = new WebSpeciesObservationSearchCriteria();
            searchCriteria.TaxonIds   = TaxonManagerTest.GetSomeTaxonIds(1);
            searchCriteria.UserRoleId = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            searchCriteria.Accuracy   = 1000;
            speciesObservationCount   = SpeciesObservationManager.GetSpeciesObservationCountBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsTrue(speciesObservationCount > 0);

            // Test observer search string.
            searchCriteria             = new WebSpeciesObservationSearchCriteria();
            searchCriteria.UserRoleId  = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            searchCriteria.DatabaseIds = new List <Int32>();
            searchCriteria.DatabaseIds.Add(7);
            searchCriteria.ObserverSearchString = "";
            speciesObservationCount             = SpeciesObservationManager.GetSpeciesObservationCountBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsTrue(speciesObservationCount > 0);
        }
Esempio n. 13
0
 public void CheckData()
 {
     GetUserParameterSelection(true).TaxonIds = TaxonManagerTest.GetSomeTaxonIds();
     GetUserParameterSelection().CheckData();
 }
 public static DataTable GetUserSelectedHosts(WebServiceContext context)
 {
     return(GetUserSelectedHosts(context, TaxonManagerTest.GetSomeTaxonIds(2)));
 }
        public void GetSpeciesFactsByUserParameterSelection()
        {
            List <Int32> factorIds, hostIds, individualCategoryIds,
                         periodIds, referenceIds, taxonIds;
            List <WebSpeciesFact>     speciesFacts;
            WebUserParameterSelection userParameterSelection;
            Int32 speciesFactCount;

            userParameterSelection = new WebUserParameterSelection();
            factorIds             = FactorManagerTest.GetSomeFactorIds();
            hostIds               = TaxonManagerTest.GetSomeTaxonIds();
            individualCategoryIds = IndividualCategoryManagerTest.GetSomeIndividualCategoryIds(GetContext());
            individualCategoryIds.RemoveAt(0);
            periodIds = PeriodManagerTest.GetSomePeriodIds(GetContext());
            periodIds.RemoveAt(periodIds.Count - 2);
            periodIds.RemoveAt(periodIds.Count - 2);
            referenceIds = ReferenceManagerTest.GetSomeReferenceIds(GetContext());
            taxonIds     = TaxonManagerTest.GetSomeTaxonIds();

            userParameterSelection.TaxonIds = taxonIds;
            speciesFacts = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(GetContext(), userParameterSelection);
            Assert.IsTrue(speciesFacts.IsNotEmpty());
            speciesFactCount = speciesFacts.Count;

            userParameterSelection.FactorIds = factorIds;
            speciesFacts = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(GetContext(), userParameterSelection);
            Assert.IsTrue(speciesFacts.IsNotEmpty());
            Assert.IsTrue(speciesFactCount > speciesFacts.Count);
            userParameterSelection.FactorIds = null;

            userParameterSelection.IndividualCategoryIds = individualCategoryIds;
            speciesFacts = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(GetContext(), userParameterSelection);
            if (speciesFacts.IsNotEmpty())
            {
                Assert.IsTrue(speciesFactCount > speciesFacts.Count);
            }
            userParameterSelection.IndividualCategoryIds = null;

            userParameterSelection.PeriodIds = periodIds;
            speciesFacts = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(GetContext(), userParameterSelection);
            if (speciesFacts.IsNotEmpty())
            {
                Assert.IsTrue(speciesFactCount > speciesFacts.Count);
            }
            userParameterSelection.PeriodIds = null;

            userParameterSelection.HostIds = hostIds;
            speciesFacts = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(GetContext(), userParameterSelection);
            if (speciesFacts.IsNotEmpty())
            {
                Assert.IsTrue(speciesFactCount > speciesFacts.Count);
            }
            userParameterSelection.HostIds = null;

            userParameterSelection.ReferenceIds = referenceIds;
            speciesFacts = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(GetContext(), userParameterSelection);
            if (speciesFacts.IsNotEmpty())
            {
                Assert.IsTrue(speciesFactCount > speciesFacts.Count);
            }
            userParameterSelection.ReferenceIds = null;
        }
Esempio n. 16
0
        public void GetSpeciesObservations()
        {
            DateTime startDate;
            WebSpeciesObservationSearchCriteria searchCriteria;
            WebSpeciesObservationInformation    speciesObservationInformation;

            searchCriteria                = new WebSpeciesObservationSearchCriteria();
            searchCriteria.TaxonIds       = TaxonManagerTest.GetSomeTaxonIds(1);
            searchCriteria.UserRoleId     = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            searchCriteria.Accuracy       = 1000;
            speciesObservationInformation = SpeciesObservationManager.GetSpeciesObservations(GetContext(), searchCriteria);
            Assert.IsNotNull(speciesObservationInformation);
            Assert.IsTrue(speciesObservationInformation.SpeciesObservations.IsNotEmpty());

            // Get more species observations than
            // SpeciesObservationManager.MAX_SPECIES_OBSERVATIONS_WITH_INFORMATION.
            //searchCriteria = new WebSpeciesObservationSearchCriteria();
            //searchCriteria.TaxonIds.Add(BEWICKS_SWAN_ID);
            //searchCriteria.UserRoleId = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            //searchCriteria.Accuracy = 10000;
            //speciesObservationInformation = SpeciesObservationManager.GetSpeciesObservations(GetContext(), searchCriteria);
            //Assert.IsNotNull(speciesObservationInformation);
            //Assert.IsTrue(speciesObservationInformation.SpeciesObservations.IsEmpty());
            //Assert.IsTrue(speciesObservationInformation.SpeciesObservationIds.IsNotEmpty());
            //Assert.AreEqual(speciesObservationInformation.SpeciesObservationIds.Count, speciesObservationInformation.SpeciesObservationCount);

            // Test problem with getting observations inside an rectangle.
            searchCriteria = new WebSpeciesObservationSearchCriteria();
            searchCriteria.IsRectangleSpecified = true;
            searchCriteria.EastCoordinate       = 1296797;
            searchCriteria.NorthCoordinate      = 6363590;
            searchCriteria.SouthCoordinate      = 6350588;
            searchCriteria.WestCoordinate       = 1284223;
            searchCriteria.UserRoleId           = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            speciesObservationInformation       = SpeciesObservationManager.GetSpeciesObservations(GetContext(), searchCriteria);
            Assert.IsNotNull(speciesObservationInformation);
            Assert.IsTrue(speciesObservationInformation.SpeciesObservations.IsNotEmpty());

            // Test problem with getting observations inside an rectangle.
            searchCriteria = new WebSpeciesObservationSearchCriteria();
            searchCriteria.IncludePositiveObservations = true;
            searchCriteria.TaxonIds = new List <Int32>();
            searchCriteria.TaxonIds.Add(101656);
            searchCriteria.UseOfObservationDate = WebUseOfDate.IgnoreYear;
            searchCriteria.ObservationStartDate = new DateTime(2009, 8, 1);
            searchCriteria.ObservationEndDate   = new DateTime(2009, 8, 31);
            searchCriteria.UserRoleId           = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            speciesObservationInformation       = SpeciesObservationManager.GetSpeciesObservations(GetContext(), searchCriteria);
            Assert.IsNotNull(speciesObservationInformation);
            Assert.IsTrue(speciesObservationInformation.SpeciesObservations.IsNotEmpty());
            foreach (WebSpeciesObservation speciesObservation in speciesObservationInformation.SpeciesObservations)
            {
                startDate = speciesObservation.DataFields[4].Value.WebParseDateTime();
                Assert.AreEqual(searchCriteria.ObservationStartDate.Month,
                                startDate.Month);
                Assert.IsTrue(searchCriteria.ObservationStartDate.Day <= startDate.Day);
                Assert.IsTrue(searchCriteria.ObservationEndDate.Day >= startDate.Day);
            }

            // Test observer search string.
            searchCriteria             = new WebSpeciesObservationSearchCriteria();
            searchCriteria.UserRoleId  = WebServiceData.UserManager.GetRoles(GetContext())[0].Id;
            searchCriteria.DatabaseIds = new List <Int32>();
            searchCriteria.DatabaseIds.Add(7);
            searchCriteria.ObserverSearchString = "";
            speciesObservationInformation       = SpeciesObservationManager.GetSpeciesObservations(GetContext(), searchCriteria);
            Assert.IsNotNull(speciesObservationInformation);
            Assert.IsTrue(speciesObservationInformation.SpeciesObservations.IsNotEmpty());
        }