コード例 #1
0
        public void Should_Return_Occupied_Points_Multiple_Positions()
        {
            var points = new List <(int, int)>()
            {
                (0, 0),
                (3, 0),
                (3, 2),
            };

            var expected = new List <(int, int)>()
            {
                (0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (3, 2)
            };
            var result = LineCalculator.GetOccupiedBetweenPoints(points);

            Assert.Equal(expected, result);
        }
コード例 #2
0
        public void Should_Return_Occupied_Points()
        {
            int fromX = 0;
            int fromY = 0;

            int toX = 5;
            int toY = 0;

            var expected = new List <(int, int)> {
                (0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0)
            };

            List <(int, int)> result = LineCalculator.GetOccupiedBetweenPoints(fromX, fromY, toX, toY);

            Assert.Equal(expected, result);

            fromX = 0;
            fromY = 0;

            toX = 0;
            toY = 5;

            expected = new List <(int, int)> {
                (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)
            };

            result = LineCalculator.GetOccupiedBetweenPoints(fromX, fromY, toX, toY);
            Assert.Equal(expected, result);

            fromX = 2;
            fromY = 0;

            toX = -2;
            toY = 0;

            expected = new List <(int, int)> {
                (-2, 0), (-1, 0), (0, 0), (1, 0), (2, 0)
            };

            result = LineCalculator.GetOccupiedBetweenPoints(fromX, fromY, toX, toY);
            Assert.Equal(expected, result);
        }