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 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); }