コード例 #1
0
        public void QueryCoordTest()
        {
            var mapper = new CoordMapper(10, 10);
            var coord  = mapper.QueryCoord(0, 0);

            Assert.AreEqual(coord, new Coordinate <int>(0, 0));

            coord = mapper.QueryCoord(5, 5);
            Assert.AreEqual(coord, new Coordinate <int>(5, 5));

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => {
                coord = mapper.QueryCoord(10, 10);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => {
                coord = mapper.QueryCoord(-1, -1);
            });

            mapper.Set(4, 5);
            coord = mapper.QueryCoord(5, 5);
            Assert.AreEqual(coord, new Coordinate <int>(6, 5));

            mapper.Set(5, 5);
            coord = mapper.QueryCoord(6, 5);
            Assert.AreEqual(coord, new Coordinate <int>(8, 5));
        }
コード例 #2
0
        public void ClearTest()
        {
            var mapper = new CoordMapper(10, 10);

            mapper.Set(0, 0);
            mapper.Clear(0, 0);
            var coord = mapper.QueryCoord(1, 1);

            Assert.AreEqual(coord, new Coordinate <int>(1, 1));

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => {
                mapper.Clear(-1, -1);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => {
                mapper.Clear(423423, 413847);
            });
        }