public void AggregateValuesTest()
 {
     DefaultAggregatorImpl target = new DefaultAggregatorImpl();
     IEnumerable<INEService.IndicatorValue> indicatorValueList = new INEService.IndicatorValue[]
     {
         new INEService.IndicatorValue {
             Value = 1,
             Dimensions = new List<INEService.DimensionFilter>{
                 new INEService.DimensionFilter { Order=1, Codes = new INEService.ArrayOfDimensionCode() { "2010" } },
                 new INEService.DimensionFilter { Order=2, Codes = new INEService.ArrayOfDimensionCode() { "PT" } },
                 new INEService.DimensionFilter { Order=3, Codes = new INEService.ArrayOfDimensionCode() { "M" } }
             }
         },
         new INEService.IndicatorValue {
             Value = 1,
             Dimensions = new List<INEService.DimensionFilter>{
                 new INEService.DimensionFilter { Order=1, Codes = new INEService.ArrayOfDimensionCode() { "2010" } },
                 new INEService.DimensionFilter { Order=2, Codes = new INEService.ArrayOfDimensionCode() { "PT" } },
                 new INEService.DimensionFilter { Order=3, Codes = new INEService.ArrayOfDimensionCode() { "F" } }
             }
         },
         new INEService.IndicatorValue {
             Value = 1,
             Dimensions = new List<INEService.DimensionFilter>{
                 new INEService.DimensionFilter { Order=1, Codes = new INEService.ArrayOfDimensionCode() { "2011" } },
                 new INEService.DimensionFilter { Order=2, Codes = new INEService.ArrayOfDimensionCode() { "PT" } },
                 new INEService.DimensionFilter { Order=3, Codes = new INEService.ArrayOfDimensionCode() { "M" } }
             }
         },
         new INEService.IndicatorValue {
             Value = 1,
             Dimensions = new List<INEService.DimensionFilter>{
                 new INEService.DimensionFilter { Order=1, Codes = new INEService.ArrayOfDimensionCode() { "2011" } },
                 new INEService.DimensionFilter { Order=2, Codes = new INEService.ArrayOfDimensionCode() { "PT" } },
                 new INEService.DimensionFilter { Order=3, Codes = new INEService.ArrayOfDimensionCode() { "F" } }
             }
         }
     };
     IEnumerable<DimensionFilter> projectedDimensions = new DimensionFilter[]
     {
         new DimensionFilter { DimensionID="3", AttributeIDs=new string[]{ "M", "F" } }
     };
     IEnumerable<IndicatorValue> expected = new IndicatorValue[]
     {
         new IndicatorValue {
             Value = 2,
             Filters = new DimensionFilter[]{
                 new DimensionFilter { DimensionID = "1", AttributeIDs = new string[]{ "2010", "2011" } },
                 new DimensionFilter { DimensionID = "2", AttributeIDs = new string[]{ "PT" } },
             },
             Projected = new DimensionFilter[]{
                 new DimensionFilter { DimensionID = "3", AttributeIDs = new string[]{ "M" } }
             }
         },
         new IndicatorValue {
             Value = 2,
             Filters = new DimensionFilter[]{
                 new DimensionFilter { DimensionID = "1", AttributeIDs = new string[]{ "2010", "2011" } },
                 new DimensionFilter { DimensionID = "2", AttributeIDs = new string[]{ "PT" } },
             },
             Projected = new DimensionFilter[]{
                 new DimensionFilter { DimensionID = "3", AttributeIDs = new string[]{ "F" } }
             }
         }
     };
     IEnumerable<IndicatorValue> actual = target.AggregateValues(indicatorValueList, projectedDimensions);
     Assert.IsTrue(Enumerable.SequenceEqual<IndicatorValue>(expected, actual));
 }
        public void GetDataProjectedBySpecifiedDimensionTest()
        {
            DefaultStatisticsProxyImpl target = new DefaultStatisticsProxyImpl(configKey, indicatorRepository, factory);
            int sourceid = 1;
            int indicatorid = 1;
            IEnumerable<DimensionFilter> projectedDimensions = new DimensionFilter[]
            {
                new DimensionFilter{ DimensionID = "3", AttributeIDs = new string[]{ "M", "F" } }
            };
            IEnumerable<DimensionFilter> filterDimensions = new DimensionFilter[]
            {
                new DimensionFilter{ DimensionID = "1", AttributeIDs = new string[]{ "2010", "2011" } },
                new DimensionFilter{ DimensionID = "2", AttributeIDs = new string[]{ "PT" } }
            };

            IEnumerable<IndicatorValue> expectedValues = new IndicatorValue[] {
                new IndicatorValue {
                    Value = 2,
                    Projected = new DimensionFilter[] {
                        new DimensionFilter { DimensionID = "3", AttributeIDs = new string[] { "M" } }
                    },
                    Filters = new DimensionFilter[] {
                        new DimensionFilter{ DimensionID = "1", AttributeIDs = new List<string>{ "2010", "2011" } },
                        new DimensionFilter{ DimensionID = "2", AttributeIDs = new List<string>{ "PT" } }
                    }
                },
                new IndicatorValue {
                    Value = 4,
                    Projected = new DimensionFilter[] {
                        new DimensionFilter { DimensionID = "3", AttributeIDs = new string[] { "F" } }
                    },
                    Filters = new DimensionFilter[] {
                        new DimensionFilter{ DimensionID = "1", AttributeIDs = new List<string>{ "2010", "2011" } },
                        new DimensionFilter{ DimensionID = "2", AttributeIDs = new List<string>{ "PT" } }
                    }
                }
            };
            IndicatorValues actual = target.GetIndicatorValues(sourceid, indicatorid, filterDimensions, projectedDimensions);
            Assert.IsTrue(Enumerable.SequenceEqual<IndicatorValue>(expectedValues, actual.Values));
        }
        public void GetValuesTest()
        {
            INEService.IndicatorValues ineValues = new INEService.IndicatorValues
            {
                IndicatorValueList = new List<INEService.IndicatorValue> {
                    new INEService.IndicatorValue{
                        Value = 1,
                        IndicatorCode = "1",
                        Dimensions = new List<INEProvider.INEService.DimensionFilter>
                        {
                            new INEProvider.INEService.DimensionFilter { Order = 1, Codes = new ArrayOfDimensionCode { "S7A2010" } },
                            new INEProvider.INEService.DimensionFilter { Order = 2, Codes = new ArrayOfDimensionCode { "1" } },
                        }
                    }
                }
            };
            Mock<IINERequesterWrapper> ineMock = new Mock<IINERequesterWrapper>();
            ineMock.Setup(m => m.GetValues(
                It.IsAny<string>(),
                It.IsAny<List<INEProvider.INEService.DimensionFilter>>(),
                It.IsAny<ValuesReturnType>(),
                It.IsAny<string>(),
                It.IsAny<int>(),
                It.IsAny<int>())).Returns(ineValues);

            IEnumerable<ProviderDataContracts.Values.IndicatorValue> aggregatorValues = new ProviderDataContracts.Values.IndicatorValue[] {
                new ProviderDataContracts.Values.IndicatorValue {
                    Value = 1,
                    Filters = new List<ProviderDataContracts.Filters.DimensionFilter> {
                        new ProviderDataContracts.Filters.DimensionFilter { DimensionID = "1", AttributeIDs = new List<string> { "S7A2010" } },
                        new ProviderDataContracts.Filters.DimensionFilter { DimensionID = "2", AttributeIDs = new List<string> { "1" } }
                    }
                }
            };
            Mock<IAggregator> agregatorMock = new Mock<IAggregator>();
            agregatorMock.Setup(m => m.AggregateValues(
                It.IsAny<IEnumerable<INEService.IndicatorValue>>(),
                It.IsAny<IEnumerable<ProviderDataContracts.Filters.DimensionFilter>>())).Returns(aggregatorValues);

            INEStatisticsProvider target = new INEStatisticsProvider(ineMock.Object, agregatorMock.Object);
            string indicatorId = "1";
            IEnumerable<ProviderDataContracts.Filters.DimensionFilter> filters = null;
            IEnumerable<ProviderDataContracts.Values.IndicatorValue> expected = new List<ProviderDataContracts.Values.IndicatorValue> {
                new ProviderDataContracts.Values.IndicatorValue
                {
                    Value = 1,
                    Filters = new List<ProviderDataContracts.Filters.DimensionFilter> {
                        new ProviderDataContracts.Filters.DimensionFilter { DimensionID = "1", AttributeIDs = new List<string> { "S7A2010" } },
                        new ProviderDataContracts.Filters.DimensionFilter { DimensionID = "2", AttributeIDs = new List<string> { "1" } }
                    }
                }
            };
            IEnumerable<ProviderDataContracts.Values.IndicatorValue> actual = target.GetValues(indicatorId, null, null);
            Assert.IsTrue(Enumerable.SequenceEqual<ProviderDataContracts.Values.IndicatorValue>(expected, actual));
        }
 public void ToIndicatorValueTest()
 {
     INEService.IndicatorValue inevalue = new INEService.IndicatorValue
     {
         Value = 1,
         IndicatorCode = "1",
         Dimensions = new List<DimensionFilter>
         {
             new DimensionFilter { Order = 1, Codes = new ArrayOfDimensionCode { "S7A2010" } },
             new DimensionFilter { Order = 2, Codes = new ArrayOfDimensionCode { "1" } },
         }
     };
     ProviderDataContracts.Values.IndicatorValue expected = new ProviderDataContracts.Values.IndicatorValue
     {
         Value = 1,
         Filters = new List<ProviderDataContracts.Filters.DimensionFilter> {
             new ProviderDataContracts.Filters.DimensionFilter { DimensionID = "1", AttributeIDs = new List<string> { "S7A2010" } },
             new ProviderDataContracts.Filters.DimensionFilter { DimensionID = "2", AttributeIDs = new List<string> { "1" } }
         }
     };
     ProviderDataContracts.Values.IndicatorValue actual = IndicatorValueExtension.ToIndicatorValue(inevalue);
     Assert.AreEqual(expected, actual);
 }