Example #1
0
        public void PropagateTest()
        {
            var propagator = new Propagator(Propagator.DefaultNeighborsGetter);
            var context    = new WaterContext(_map, propagator);
            var drop       = new WaterDrop(0.1);

            context.AddDrop(drop, (2, 2));
            context.PropagateWater(WaterContext.DefaultNeighborsGetter);
            var drops = context.Drops;

            Assert.Equal(4, drops.Count);
        }
Example #2
0
        public void MergeTest()
        {
            var propagator = new Propagator(Propagator.DefaultNeighborsGetter);
            var context    = new WaterContext(_map, propagator);
            var drop       = new WaterDrop(0.1);

            context.AddDrop(drop, (2, 2));
            context.PropagateWater(WaterContext.DefaultNeighborsGetter);
            context.PropagateWater(WaterContext.DefaultNeighborsGetter);
            var dropsBefore = context.Drops.ToDictionary(x => x.Key, x => x.Value);

            context.Merge();
            var dropsAfter = context.Drops.ToDictionary(x => x.Key, x => x.Value);

            Assert.Equal(16, dropsBefore.Count);
            Assert.Equal(9, dropsAfter.Count);
        }