コード例 #1
0
        public void GetPeriodTypes()
        {
            List <WebPeriodType> periodTypes;

            UseTransaction = true;
            periodTypes    = FactorManager.GetPeriodTypes(GetContext());
            Assert.IsTrue(periodTypes.IsNotEmpty());

            UseTransaction = false;
            periodTypes    = FactorManager.GetPeriodTypes(GetContext());
            Assert.IsTrue(periodTypes.IsNotEmpty());
        }
コード例 #2
0
        public void GetFactorOrigins()
        {
            List <WebFactorOrigin> factorOrigins;

            UseTransaction = true;
            factorOrigins  = FactorManager.GetFactorOrigins(GetContext());
            Assert.IsTrue(factorOrigins.IsNotEmpty());

            UseTransaction = false;
            factorOrigins  = FactorManager.GetFactorOrigins(GetContext());
            Assert.IsTrue(factorOrigins.IsNotEmpty());
        }
コード例 #3
0
        public void GetFactorFieldTypes()
        {
            List <WebFactorFieldType> factorFieldTypes;

            UseTransaction   = true;
            factorFieldTypes = FactorManager.GetFactorFieldTypes(GetContext());
            Assert.IsTrue(factorFieldTypes.IsNotEmpty());

            UseTransaction   = false;
            factorFieldTypes = FactorManager.GetFactorFieldTypes(GetContext());
            Assert.IsTrue(factorFieldTypes.IsNotEmpty());
        }
コード例 #4
0
        public void GetIndividualCategories()
        {
            List <WebIndividualCategory> individualCategories;

            UseTransaction       = true;
            individualCategories = FactorManager.GetIndividualCategories(GetContext());
            Assert.IsTrue(individualCategories.IsNotEmpty());

            UseTransaction       = false;
            individualCategories = FactorManager.GetIndividualCategories(GetContext());
            Assert.IsTrue(individualCategories.IsNotEmpty());
        }
コード例 #5
0
        public void GetFactorTrees()
        {
            List <WebFactorTreeNode> factorTrees;

            UseTransaction = true;
            factorTrees    = FactorManager.GetFactorTrees(GetContext());
            Assert.IsTrue(factorTrees.IsNotEmpty());

            UseTransaction = false;
            factorTrees    = FactorManager.GetFactorTrees(GetContext());
            Assert.IsTrue(factorTrees.IsNotEmpty());
            CheckCircularTree(factorTrees);
        }
コード例 #6
0
        public void GetFactorTreesByIdsAndSearchCriteria_UserCanReadAllFactors_GetNonPublicFactor_ExpectsFactorTree()
        {
            List <Int32>                factorIds = new List <Int32>();
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria();

            factorIds.Add(1872);

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsNotEmpty());
            Console.WriteLine("factorTrees.Count: " + factorTrees.Count);
            Assert.AreEqual(factorTrees.Count, 1);
            Console.WriteLine("factorTrees[0].Children.Count: " + factorTrees[0].Children.Count);
            Assert.AreEqual(factorTrees[0].Children.Count, 4);
        }
コード例 #7
0
        public void GetFactorTreesByIdsAndSearchCriteria_UserCanReadOnlyPublicFactors_GetNonPublicFactor_ExpectsNoFactorTree()
        {
            SetUserAndApplicationIdentifier("testUserPublic", ApplicationIdentifier.EVA.ToString());

            List <Int32>                factorIds = new List <Int32>();
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria();

            factorIds.Add(1872);

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsEmpty());
            Console.WriteLine("factorTrees.Count: " + factorTrees.Count);
            Assert.AreEqual(factorTrees.Count, 0);
        }
コード例 #8
0
        public void GetFactorTreesByIdsAndSearchCriteria()
        {
            List <Int32>                factorIds = new List <Int32>();
            List <WebFactorTreeNode>    factorTrees;
            WebFactorTreeSearchCriteria searchCriteria = new WebFactorTreeSearchCriteria();

            factorIds.Add(661);

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.IsTrue(factorTrees.IsNotEmpty());

            searchCriteria.FactorIds = factorIds;
            factorTrees = FactorManager.GetFactorTreesBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsNotNull(factorTrees);
            Assert.AreEqual(factorTrees.Count, 1);
            Assert.AreEqual(factorTrees[0].Children.Count, 9);
        }
コード例 #9
0
        public void GetFactorDataTypes()
        {
            List <WebFactorDataType> factorDataTypes;

            UseTransaction  = true;
            factorDataTypes = FactorManager.GetFactorDataTypes(GetContext());
            Assert.IsTrue(factorDataTypes.IsNotEmpty());
            foreach (WebFactorDataType factorDataType in factorDataTypes)
            {
                Assert.IsTrue(factorDataType.Fields.IsNotEmpty());
            }

            UseTransaction  = false;
            factorDataTypes = FactorManager.GetFactorDataTypes(GetContext());
            Assert.IsTrue(factorDataTypes.IsNotEmpty());
            foreach (WebFactorDataType factorDataType in factorDataTypes)
            {
                Assert.IsTrue(factorDataType.Fields.IsNotEmpty());
            }
        }
コード例 #10
0
        public void GetFactorFieldEnums()
        {
            List <WebFactorFieldEnum> factorFieldEnums;

            UseTransaction   = true;
            factorFieldEnums = FactorManager.GetFactorFieldEnums(GetContext());
            Assert.IsTrue(factorFieldEnums.IsNotEmpty());
            foreach (WebFactorFieldEnum factorFieldEnum in factorFieldEnums)
            {
                Assert.IsTrue(factorFieldEnum.Values.IsNotEmpty());
            }

            UseTransaction   = false;
            factorFieldEnums = FactorManager.GetFactorFieldEnums(GetContext());
            Assert.IsTrue(factorFieldEnums.IsNotEmpty());
            foreach (WebFactorFieldEnum factorFieldEnum in factorFieldEnums)
            {
                Assert.IsTrue(factorFieldEnum.Values.IsNotEmpty());
            }
        }
        private WebFactorField GetFactorField(Int32 factorDataTypeId,
                                              String databaseFieldName)
        {
            List <WebFactorDataType> factorDataTypes;

            factorDataTypes = FactorManager.GetFactorDataTypes(GetContext());
            foreach (WebFactorDataType factorDataType in factorDataTypes)
            {
                if (factorDataType.Id == factorDataTypeId)
                {
                    foreach (WebFactorField factorField in factorDataType.Fields)
                    {
                        if (factorField.DatabaseFieldName == databaseFieldName)
                        {
                            return(factorField);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #12
0
        public void GetFactorsBySearchCriteria()
        {
            List <WebFactor>        factors;
            List <Int32>            factorIds;
            Int32                   factorCount1, factorCount2;
            WebFactorSearchCriteria searchCriteria;

            searchCriteria = new WebFactorSearchCriteria();
            searchCriteria.NameSearchString = null;
            factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsTrue(factors.IsNull() || factors.IsEmpty());

            searchCriteria.NameSearchString = new WebStringSearchCriteria();
            searchCriteria.NameSearchString.SearchString     = "Rödli%";
            searchCriteria.NameSearchString.CompareOperators = new List <StringCompareOperator>();
            searchCriteria.NameSearchString.CompareOperators.Add(StringCompareOperator.Like);
            factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsFalse(factors.IsNull() || factors.IsEmpty());

            searchCriteria.NameSearchString = new WebStringSearchCriteria();
            searchCriteria.NameSearchString.SearchString     = "Rödli";
            searchCriteria.NameSearchString.CompareOperators = new List <StringCompareOperator>();
            searchCriteria.NameSearchString.CompareOperators.Add(StringCompareOperator.Equal);
            searchCriteria.NameSearchString.CompareOperators.Add(StringCompareOperator.BeginsWith);
            searchCriteria.NameSearchString.CompareOperators.Add(StringCompareOperator.Contains);
            factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsTrue(factors.IsNotEmpty());

            searchCriteria.NameSearchString = new WebStringSearchCriteria();
            searchCriteria.NameSearchString.SearchString     = "Landskapstyper";
            searchCriteria.NameSearchString.CompareOperators = new List <StringCompareOperator>();
            searchCriteria.NameSearchString.CompareOperators.Add(StringCompareOperator.Equal);
            factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsFalse(factors.IsNull() || factors.IsEmpty());
            factorCount1 = factors.Count;
            Assert.IsNotNull(factorCount1);
            Assert.IsTrue(factorCount1 > 0);

            searchCriteria.NameSearchString = new WebStringSearchCriteria();
            searchCriteria.NameSearchString.SearchString     = "661";
            searchCriteria.NameSearchString.CompareOperators = new List <StringCompareOperator>();
            searchCriteria.NameSearchString.CompareOperators.Add(StringCompareOperator.Like);
            searchCriteria.IsIdInNameSearchString = true;
            factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsTrue(factors.IsNotEmpty());
            factorCount2 = factors.Count;
            Assert.AreEqual(factorCount1, factorCount2);

            searchCriteria = new WebFactorSearchCriteria();
            factorIds      = new List <Int32>();
            factorIds.Add(661);
            searchCriteria.RestrictSearchToFactorIds = factorIds;
            searchCriteria.RestrictReturnToScope     = FactorSearchScope.AllChildFactors;
            factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
            Assert.IsFalse(factors.IsNull() || factors.IsEmpty());
            Assert.AreEqual(factors.Count, 10);

            foreach (FactorSearchScope factorSearchScope in Enum.GetValues(typeof(FactorSearchScope)))
            {
                searchCriteria = new WebFactorSearchCriteria();
                searchCriteria.RestrictSearchToFactorIds = factorIds;
                searchCriteria.RestrictReturnToScope     = factorSearchScope;
                factors = FactorManager.GetFactorsBySearchCriteria(GetContext(), searchCriteria);
                Assert.IsFalse(factors.IsNull() || factors.IsEmpty());
            }
        }