예제 #1
0
        public void PolygonService_SerializeAll_DeseriallizeAll_Test()
        {
            Polygon myPolygon = new Polygon();

            myPolygon.Stroke          = Brushes.Black;
            myPolygon.Fill            = Brushes.LightSeaGreen;
            myPolygon.StrokeThickness = 5;
            Point           Point1            = new Point(1, 50);
            Point           Point2            = new Point(10, 80);
            Point           Point3            = new Point(50, 50);
            PointCollection myPointCollection = new PointCollection();

            myPointCollection.Add(Point1);
            myPointCollection.Add(Point2);
            myPointCollection.Add(Point3);
            myPolygon.Points = myPointCollection;
            PolygonsService ps = new PolygonsService();

            ps.repo.Add(myPolygon);
            string path = "C:/Users/Hp/Desktop/Team_NAME/FiguresTask/UnitTests/bin/Debug/rez.txt";

            ps.SerealizeAll(path);
            List <Polygon> polArr = (ps.DeserializeAll(path)).ToList();

            Assert.AreEqual(5, polArr[0].StrokeThickness);
        }
예제 #2
0
        public void PolygonService_GetPolygon_Test()
        {
            Point        Point1     = new Point(1, 50);
            Point        Point2     = new Point(10, 80);
            Point        Point3     = new Point(50, 50);
            List <Point> pointsList = new List <Point>();

            pointsList.Add(Point1);
            pointsList.Add(Point2);
            pointsList.Add(Point3);
            Color color = new Color();

            color = Color.FromRgb(255, 0, 0);
            PolygonModel    pm        = new PolygonModel(pointsList, color, 1);
            PolygonsService ps        = new PolygonsService();
            Polygon         myPolygon = ps.GetPolygon(pm);

            Assert.AreEqual(myPolygon.StrokeThickness, 1);
        }