Example #1
0
        private static WinPivotGridField GetIAvrPivotGridField(string fieldName)
        {
            var field = new WinPivotGridField
            {
                Name      = @"field" + fieldName,
                FieldName = fieldName,
                Caption   = @"caption " + fieldName,
                Area      = PivotArea.RowArea,
                Visible   = true,
            };

            return(field);
        }
Example #2
0
        public void FieldNameSimpleTest()
        {
            var field = new WinPivotGridField
            {
                Name      = @"field" + FieldName,
                FieldName = FieldName,
                Caption   = @"Some caption",
                Area      = PivotArea.DataArea,
                Visible   = true,
            };

            Assert.AreEqual(FieldName, field.FieldName);
            Assert.AreEqual(@"field" + FieldName, field.Name);
            Assert.AreEqual(FieldName, field.OriginalFieldName);
            Assert.AreEqual(-1L, field.FieldId);
        }
Example #3
0
        public void PivotGridLinkedFieldRayonRegionSettlementTest()
        {
            WinPivotGridField region = GetIAvrPivotGridField("Region");
            WinPivotGridField rayon  = GetIAvrPivotGridField("Rayon");

            rayon.RelatedFields = new List <IAvrPivotGridField> {
                region
            };
            WinPivotGridField settlement = GetIAvrPivotGridField("Settlement");

            settlement.RelatedFields = new List <IAvrPivotGridField> {
                rayon, region
            };
            WinPivotGridField diagnosis = GetIAvrPivotGridField("Diagnosis");
            WinPivotGridField zoonotic  = GetIAvrPivotGridField("Zoonotic");

            zoonotic.RelatedFields = new List <IAvrPivotGridField> {
                diagnosis
            };

            var allFields = new List <IAvrPivotGridField> {
                region, rayon, settlement, diagnosis, zoonotic
            };

            foreach (IAvrPivotGridField field in allFields)
            {
                field.AllPivotFields = allFields;
            }

            Assert.AreEqual(2, settlement.GetRelatedFieldChain().Count);
            Assert.AreEqual(1, zoonotic.GetRelatedFieldChain().Count);

            var fields = new List <IAvrPivotGridField> {
                rayon, region, settlement, zoonotic
            };
            List <IAvrPivotGridField> result = AvrPivotGridHelper.AddRelatedFields(fields).ToList();

            Assert.AreEqual(5, result.Count);
            Assert.AreEqual(region, result[0]);
            Assert.AreEqual(rayon, result[1]);
            Assert.AreEqual(settlement, result[2]);
            Assert.AreEqual(diagnosis, result[3]);
            Assert.AreEqual(zoonotic, result[4]);
        }