public void Filter() { IList <WeightedItem> weightedItems = new List <WeightedItem>(); IEnumerable <MapItem> actual = this.filter.Filter(weightedItems, new double[] { }, 100); ComparisonHelper.CheckTotalPointsCount(0, actual); MapPath mapPath1 = new MapPath(); MapPathSegment segment1 = MapUtils.CreateSegment(4); mapPath1.Segments.Add(segment1); IList <IList <double> > weights1 = new List <IList <double> > { new double[] { 1, 2 } }; weightedItems = new List <WeightedItem> { new WeightedItem(mapPath1, weights1) }; actual = this.filter.Filter(weightedItems, new double[] { 1, 2 }, 100); ComparisonHelper.CheckTotalPointsCount(4, actual); actual = this.filter.Filter(weightedItems, new double[] { 1, 2 }, 0); ComparisonHelper.CheckTotalPointsCount(2, actual); mapPath1.Segments.Add(segment1); weights1.Add(new double[] { 1, 2 }); actual = this.filter.Filter(weightedItems, new double[] { 1, 1, 2, 2 }, 49); ComparisonHelper.CheckTotalPointsCount(6, actual); MapPathSegment segment2 = MapUtils.CreateSegment(5); MapPath mapPath2 = new MapPath(); mapPath2.Segments.Add(segment2); IList <IList <double> > weights2 = new List <IList <double> > { new double[] { 1, 2, 3 } }; weightedItems.Add(new WeightedItem(mapPath2, weights2)); actual = this.filter.Filter(weightedItems, new double[] { 1, 1, 1, 2, 2, 2, 3 }, 50); ComparisonHelper.CheckTotalPointsCount(10, actual); }
public void Process() { List <MapItem> items = new List <MapItem>(); MapPath mapPath1 = new MapPath(); items.Add(mapPath1); MapPathSegment segment1 = MapUtils.CreateSegment(4); mapPath1.Segments.Add(segment1); this.calculator.Process(items); IList <IList <double> > weights1 = new List <IList <double> > { new double[] { 1, 2 } }; IList <WeightedItem> expectedWeightedItems = new List <WeightedItem> { new WeightedItem(mapPath1, weights1) }; Assert.AreEqual(new double[] { 1, 2 }, this.calculator.Weights); ComparisonHelper.AssertWeightedItems(expectedWeightedItems, this.calculator.WeightedItems); mapPath1.Segments.Add(segment1); this.calculator.Process(items); weights1.Add(new double[] { 1, 2 }); Assert.AreEqual(new double[] { 1, 2 }, this.calculator.Weights); ComparisonHelper.AssertWeightedItems(expectedWeightedItems, this.calculator.WeightedItems); MapPathSegment segment2 = MapUtils.CreateSegment(6); MapPath mapPath2 = new MapPath(); mapPath2.Segments.Add(segment2); items.Add(mapPath2); this.calculator.Process(items); IList <IList <double> > weights2 = new List <IList <double> >(); weights2.Add(new double[] { 1, 2, double.PositiveInfinity, 1 }); expectedWeightedItems.Add(new WeightedItem(mapPath2, weights2)); Assert.AreEqual(new double[] { 1, 1, 2 }, this.calculator.Weights); ComparisonHelper.AssertWeightedItems(expectedWeightedItems, this.calculator.WeightedItems); }