Esempio n. 1
0
        public void testMapServiceStartTraversingFromOceansNumberOfVisitedCells2()
        {
            //0     1       10
            //10    8       10
            //10    1       0
            IMap map = new Map(3, 3, 0, 1, 10, 10, 8, 10, 10, 1, 0);

            IMapService service = new MapServiceStartTraversingFromOceans(map);

            IServiceResult result = service.FindAllRiverSourcesWhichFlowToBothOceans();

            Assert.AreEqual(14, result.TotalCountOfVisitedCells, "Wrong number of visited cells for MapServiceStartTraversingFromOceans.");
        }
Esempio n. 2
0
        public void testMapServiceStartTraversingFromOceansNumberOfVisitedCells1()
        {
            //0     23       246       245     225     205     88
            //114   98       220       129     241     112     254
            //173   207      231       246     125     57      251
            //22    70       105       146     127     113     188
            //55   33        158       107     19      71      137
            //73   92        80        155     161     13      0

            IMap map = new Map(6, 7, 0, 23, 246, 245, 225, 205, 88, 114, 98, 220, 129, 241, 112, 254, 173, 207, 231, 246, 125, 57, 251,
                               22, 70, 105, 146, 127, 113, 188, 55, 33, 158, 107, 19, 71, 137, 73, 92, 80, 155, 161, 13, 0);

            IMapService    service = new MapServiceStartTraversingFromOceans(map);
            IServiceResult result  = service.FindAllRiverSourcesWhichFlowToBothOceans();

            Assert.AreEqual(22, result.TotalCountOfVisitedCells, "Wrong number of visited cells for MapServiceStartTraversingFromOceans.");
        }
Esempio n. 3
0
        public void testMapServiceStartTraversingFromOceansOneHit()
        {
            //0     23       246       245     225     205     88
            //114   98       220       129     241     112     254
            //173   207      231       246     125     57      251
            //22    70       105       146     127     113     188
            //55   33        158       107     19      71      137
            //73   92        80        155     161     13      0

            IMap map = new Map(6, 7, 0, 23, 246, 245, 225, 205, 88, 114, 98, 220, 129, 241, 112, 254, 173, 207, 231, 246, 125, 57, 251,
                               22, 70, 105, 146, 127, 113, 188, 55, 33, 158, 107, 19, 71, 137, 73, 92, 80, 155, 161, 13, 0);

            IMapService            service = new MapServiceStartTraversingFromOceans(map);
            IEnumerable <IMapCell> sources = service.FindAllRiverSourcesWhichFlowToBothOceans().Sources;

            Assert.AreEqual(1, sources.Count(), "Wrong number of sources.");
            Assert.IsTrue(sources.Contains(map.GetCell(2, 3)), "Wrong source.");
        }
Esempio n. 4
0
        public void testMapServiceStartTraversingFromOceansNoHits()
        {
            //0     101       199       139     168     210     45
            //107   104       246       183     115     113     171
            //122   209       42        12      15      7       219
            //41    146       210       1       53      175     210
            //203   62        182       52      163     224     242
            //151   28        105       222     140     196     0

            IMap map = new Map(6, 7, 0, 101, 199, 139, 168, 210, 45, 107, 104, 246, 183, 115, 113, 171, 122, 209, 42, 12, 15, 7, 219, 41, 146, 210, 1, 53, 175, 210,
                               203, 62, 182, 52, 163, 224, 242, 151, 28, 105, 222, 140, 196, 0);

            IMapService service = new MapServiceStartTraversingFromOceans(map);

            IEnumerable <IMapCell> sources = service.FindAllRiverSourcesWhichFlowToBothOceans().Sources;

            Assert.AreEqual(0, sources.Count(), "Wrong number of sources.");
        }
Esempio n. 5
0
        public void testMapServiceStartTraversingFromOceansMultipleHits()
        {
            //0     1       10
            //10    8       10
            //10    1       0
            IMap map = new Map(3, 3, 0, 1, 10, 10, 8, 10, 10, 1, 0);

            IMapService service = new MapServiceStartTraversingFromOceans(map);

            IEnumerable <IMapCell> sources = service.FindAllRiverSourcesWhichFlowToBothOceans().Sources;

            Assert.AreEqual(5, sources.Count(), "Wrong number of sources.");

            Assert.IsTrue(sources.Contains(map.GetCell(1, 1)), "Missing source.");
            Assert.IsTrue(sources.Contains(map.GetCell(1, 0)), "Missing source.");
            Assert.IsTrue(sources.Contains(map.GetCell(2, 0)), "Missing source.");
            Assert.IsTrue(sources.Contains(map.GetCell(0, 2)), "Missing source.");
            Assert.IsTrue(sources.Contains(map.GetCell(1, 2)), "Missing source.");
        }
Esempio n. 6
0
        private static IServiceResult TraverseFromOceans(IMap map)
        {
            IMapService service = new MapServiceStartTraversingFromOceans(map);

            return(service.FindAllRiverSourcesWhichFlowToBothOceans());
        }