示例#1
0
        public static void Insert_Throws_Index_Out_of_Range_Exception_for_Out_of_Range_Index()
        {
            List <CartesianCoordinate> coordinates = new List <CartesianCoordinate>()
            {
                new CartesianCoordinate(0, 0),
                new CartesianCoordinate(1, 2),
                new CartesianCoordinate(3, 4),
                new CartesianCoordinate(5, 6)
            };

            PointBoundary boundary = new PointBoundary(coordinates);

            Assert.Throws <IndexOutOfRangeException>(() => boundary.Insert(4, new CartesianCoordinate(7, 8)));
        }
示例#2
0
        public static void Insert_Inserts_Coordinate_at_Specified_Index()
        {
            List <CartesianCoordinate> coordinates = new List <CartesianCoordinate>()
            {
                new CartesianCoordinate(0, 0),
                new CartesianCoordinate(1, 2),
                new CartesianCoordinate(3, 4),
                new CartesianCoordinate(5, 6)
            };

            PointBoundary boundary = new PointBoundary(coordinates);

            Assert.AreEqual(4, boundary.Count);
            Assert.AreEqual(3, boundary[2].X);
            Assert.AreEqual(4, boundary[2].Y);

            CartesianCoordinate newCoordinate = new CartesianCoordinate(7, 8);

            boundary.Insert(2, newCoordinate);
            Assert.AreEqual(5, boundary.Count);
            Assert.AreEqual(newCoordinate.X, boundary[2].X);
            Assert.AreEqual(newCoordinate.Y, boundary[2].Y);
        }