Exemple #1
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

        private UserDataSet GetUserDataSet()
        {
            if (_userDataSet.IsNull())
            {
                _userDataSet = new UserDataSet();
                UserParameterSelection userParameterSelection = UserParameterSelectionTest.GetUserParameterSelection();
                userParameterSelection.Taxa.Merge(TaxonManagerTest.GetTaxaList());
                Data.ArtDatabankenService.FactorList factors = new Data.ArtDatabankenService.FactorList();
                factors.Add(ArtDatabanken.Data.ArtDatabankenService.FactorManager.GetFactor(LANDSCAPE_FACTOR_ID));
                userParameterSelection.Factors.Merge(factors);
                _userDataSet = Data.ArtDatabankenService.SpeciesFactManager.GetUserDataSetByParameterSelection(userParameterSelection);
            }

            return(_userDataSet);
        }
 public static Data.ArtDatabankenService.FactorList GetSomeNoHeaderNoPeriodicFactors()
 {
     Data.ArtDatabankenService.FactorList list = new Data.ArtDatabankenService.FactorList();
     Data.ArtDatabankenService.FactorList initialList;
     initialList = Data.ArtDatabankenService.FactorManager.GetFactors(new List <int> {
         983, 984, 743, 123, 435
     });
     foreach (Data.ArtDatabankenService.Factor factor in initialList)
     {
         if (!factor.FactorUpdateMode.IsHeader)
         {
             if (!factor.IsPeriodic)
             {
                 list.Add(factor);
             }
         }
     }
     return(list);
 }
        public void GetUserDataSetByParameterSelection()
        {
            UserDataSet            userDataSet = null, userDataSet2;
            UserParameterSelection userParmeterSelection;

            userParmeterSelection = new UserParameterSelection();

            userParmeterSelection.Taxa.Merge(ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxa(TaxonManagerTest.GetTaxaIds(), TaxonInformationType.Basic));
            Data.ArtDatabankenService.FactorList factors;
            factors = new Data.ArtDatabankenService.FactorList();
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(LANDSCAPE_FACTOR_ID));
            userParmeterSelection.Factors.Merge(factors);

            userDataSet = Data.ArtDatabankenService.SpeciesFactManager.GetUserDataSetByParameterSelection(userParmeterSelection);
            Assert.IsNotNull(userDataSet);
            Assert.IsTrue(userDataSet.SpeciesFacts.IsNotEmpty());
            Assert.IsTrue(userDataSet.SpeciesFacts.Count > 2);

            // Test problem where automatic SpeciesFact is
            // added to the UserDataSet but dependent
            // SpeicesFact is not in the UserDataSet.
            userParmeterSelection = new UserParameterSelection();
            userParmeterSelection.Taxa.Add(TaxonManagerTest.GetOneTaxon());
            userParmeterSelection.Factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.RedListCategoryAutomatic));
            userDataSet = Data.ArtDatabankenService.SpeciesFactManager.GetUserDataSetByParameterSelection(userParmeterSelection);
            Assert.IsTrue(userDataSet.SpeciesFacts.IsNotEmpty());
            Assert.IsTrue(userDataSet.Factors.Count > 30);

            // Test problem where periodic SpeciesFact are combined
            // with none default IndividualCategory.
            userParmeterSelection = new UserParameterSelection();
            userParmeterSelection.Taxa.Add(TaxonManagerTest.GetOneTaxon());
            userParmeterSelection.Factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.PopulationSize_Total));
            userDataSet = Data.ArtDatabankenService.SpeciesFactManager.GetUserDataSetByParameterSelection(userParmeterSelection);
            userParmeterSelection.IndividualCategories.Add(IndividualCategoryManager.GetIndividualCategory(INDIVIDUAL_CATEGORY_ID_IMAGO));
            userDataSet2 = Data.ArtDatabankenService.SpeciesFactManager.GetUserDataSetByParameterSelection(userParmeterSelection);
            Assert.AreEqual(userDataSet.SpeciesFacts.Count, userDataSet2.SpeciesFacts.Count);
        }
        public void GetDyntaxaSpeciesFactsByUserParameterSelection()
        {
            Data.ArtDatabankenService.FactorList factors;
            Int32 count;

            Data.ArtDatabankenService.SpeciesFactList speciesFacts;
            Data.ArtDatabankenService.TaxonList       taxa;
            UserParameterSelection userParmeterSelection;

            Data.ArtDatabankenService.Taxon lumpedTaxon = Data.ArtDatabankenService.TaxonManager.GetTaxon((Int32)(TaxonId.Bear), TaxonInformationType.Basic);

            userParmeterSelection = new UserParameterSelection();
            factors = new Data.ArtDatabankenService.FactorList();
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.SwedishOccurrence));
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.SwedishHistory));
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.QualityInDyntaxa));
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.NumberOfSwedishSpecies));
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.BanndedForReporting));
            factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.ExcludeFromReportingSystem));

            taxa = new Data.ArtDatabankenService.TaxonList();
            taxa.Add(lumpedTaxon);

            userParmeterSelection.Taxa.Merge(taxa);
            speciesFacts = Data.ArtDatabankenService.SpeciesFactManager.GetDyntaxaSpeciesFactsByUserParameterSelection(userParmeterSelection);
            Assert.IsTrue(speciesFacts.IsNotEmpty());
            count = speciesFacts.Count;

            userParmeterSelection.Factors.Merge(factors);
            speciesFacts = Data.ArtDatabankenService.SpeciesFactManager.GetDyntaxaSpeciesFactsByUserParameterSelection(userParmeterSelection);
            if (speciesFacts.IsNotEmpty())
            {
                Assert.IsTrue(count > speciesFacts.Count);
            }



            //TestUpdateSpeciesFacts
            Data.ArtDatabankenService.SpeciesFact numberOfSpecies1 = speciesFacts.GetSpeciesFactsByParameters(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.NumberOfSwedishSpecies))[0];
            Int32 testValue     = 1001;
            Int32 originalValue = Int32.MinValue;

            if (numberOfSpecies1.MainField.HasValue)
            {
                originalValue = numberOfSpecies1.MainField.Int32Value;
            }
            numberOfSpecies1.MainField.Value = testValue;

            //This is the critical part of the test but as the method should be restricted to Dyntaxa it is not possible to run it by EVA. Change Application to Dyntaxa in testBase

            /*
             * using (WebTransaction transaction = new WebTransaction(5))
             * {
             *  SpeciesFactManager.UpdateDyntaxaSpeciesFacts(speciesFacts, ReferenceManagerTest.GetAReference(), "DyntaxaTestPerson");
             *  speciesFacts = SpeciesFactManager.GetDyntaxaSpeciesFactsByUserParameterSelection(userParmeterSelection);
             *  numberOfSpecies2 = speciesFacts.GetSpeciesFactsByParameters(ArtDatabanken.Data.ArtDatabankenService.FactorManager.GetFactor(FactorId.NumberOfSwedishSpecies))[0];
             *  savedValue = numberOfSpecies2.MainField.Int32Value;
             * }
             * Assert.AreNotEqual(originalValue, savedValue);
             * Assert.AreEqual(testValue, savedValue);
             * Assert.AreEqual("DyntaxaTestPerson", numberOfSpecies2.UpdateUserFullName);
             */
        }