示例#1
0
        public void TestMultiDistricts(int testNo, string city, string[] districts, string[] towns,
                                       int[] totalMrs, int[] firstNeighbors, int[] secondNeighbors, int districtCounts,
                                       int[] districtMrs, int[] districtFirsts, int[] districtSeconds)
        {
            var townViews = towns.Select((t, i) => new TownPreciseView
            {
                City            = city,
                District        = districts[i],
                Town            = t,
                TotalMrs        = totalMrs[i],
                FirstNeighbors  = firstNeighbors[i],
                SecondNeighbors = secondNeighbors[i]
            }).ToList();
            var districtViews = PreciseRegionStatService.Merge(townViews);

            Assert.AreEqual(districtViews.Count(), districtCounts);
            for (var i = 0; i < districtCounts; i++)
            {
                PreciseViewTestService.AssertEqual(districtViews.ElementAt(i), new DistrictPreciseView
                {
                    City            = city,
                    District        = districts[i],
                    TotalMrs        = districtMrs[i],
                    FirstNeighbors  = districtFirsts[i],
                    SecondNeighbors = districtSeconds[i]
                });
            }
        }
示例#2
0
        public void TestOneDistrict(string city, string district, string[] towns, int[] totalMrs, int[] firstNeighbors,
                                    int[] secondNeighbors)
        {
            var townViews = towns.Select((t, i) => new TownPreciseView
            {
                City            = city,
                District        = district,
                Town            = t,
                TotalMrs        = totalMrs[i],
                FirstNeighbors  = firstNeighbors[i],
                SecondNeighbors = secondNeighbors[i]
            }).ToList();
            var districtViews = PreciseRegionStatService.Merge(townViews);

            Assert.AreEqual(districtViews.Count(), 1);
            PreciseViewTestService.AssertEqual(districtViews.ElementAt(0), new DistrictPreciseView
            {
                City            = city,
                District        = district,
                TotalMrs        = totalMrs.Sum(),
                FirstNeighbors  = firstNeighbors.Sum(),
                SecondNeighbors = secondNeighbors.Sum()
            });
        }