Esempio n. 1
0
 public void MPathStartEndValuesTest()
 {
     string svgPath1 = "M18,24";
     string svgPath2 = "m18,24";
     PathCommand command1 = new PathCommand(svgPath1);
     PathCommand command2 = new PathCommand(svgPath1, 10, 20);
     PathCommand command3 = new PathCommand(svgPath2);
     PathCommand command4 = new PathCommand(svgPath2, 10, 20);
     Assert.True(command1.StartX == 0);
     Assert.True(command1.StartY == 0);
     Assert.True(command1.EndX == 18);
     Assert.True(command1.EndY == 24);
     Assert.True(command2.StartX == 10);
     Assert.True(command2.StartY == 20);
     Assert.True(command2.EndX == 18);
     Assert.True(command2.EndY == 24);
     Assert.True(command3.StartX == 0);
     Assert.True(command3.StartY == 0);
     Assert.True(command3.EndX == 18);
     Assert.True(command3.EndY == 24);
     Assert.True(command4.StartX == 10);
     Assert.True(command4.StartY == 20);
     Assert.True(command4.EndX == 28);
     Assert.True(command4.EndY == 44);
     Assert.True(command1.CenterX == 18);
     Assert.True(command1.CenterY == 24);
     Assert.True(command1.RadiusX == 0);
     Assert.True(command1.RadiusY == 0);
 }
Esempio n. 2
0
        public void EqualsShouldReturnTrueOnSameValues1()
        {
            PathCommand command1 = new PathCommand("M64,32");
            PathCommand command2 = new PathCommand("m64,32");

            Assert.True(command1.Equals(command2));
        }
Esempio n. 3
0
        public void EqualsShouldReturnTrueOnSameValues2()
        {
            PathCommand command1 = new PathCommand("A32,16 0 1,0 10,64", 10, 10);
            PathCommand command2 = new PathCommand("a32,16 0 1,0 0,54", 10, 10);

            Assert.True(command1.Equals(command2));
        }
Esempio n. 4
0
 public void GetPathShouldReturnCorrectPath4()
 {
     string path = "a32,32 0 0,1 64,0";
     PathCommand sut = new PathCommand(path, 10, 20);
     Assert.True(sut.GetRelativePath() == "a32,32 0 0,1 64,0");
     Assert.True(sut.GetAbsolutePath() == "A32,32 0 0,1 74,20");
 }
Esempio n. 5
0
 public void GetPathShouldReturnCorrectPath1()
 {
     string path = "A32,32 0 0,1 82,64";
     PathCommand sut = new PathCommand(path);
     Assert.True(sut.GetRelativePath() == "a32,32 0 0,1 82,64");
     Assert.True(sut.GetAbsolutePath() == "A32,32 0 0,1 82,64");
 }
Esempio n. 6
0
 public void MPathCommandIsTest()
 {
     PathCommand command = new PathCommand("M18,24");
     Assert.True(command.IsMoveToCommand());
     Assert.False(command.IsArcCommand());
     Assert.False(command.IsUpper());
     Assert.False(command.IsLower());
     Assert.False(command.IsRight());
     Assert.False(command.IsLeft());
 }
Esempio n. 7
0
        public void ConstructorShouldSetCorrectValues2()
        {
            //Half circle right to left, clockwise
            string path = "A32,32 0 0,1 -54,-20";
            PathCommand sut = new PathCommand(path, 10, 20);

            Assert.Equal(10, sut.StartX);
            Assert.Equal(20, sut.StartY);
            Assert.Equal(-54, sut.EndX);
            Assert.Equal(-20, sut.EndY);
        }
Esempio n. 8
0
        public void ConstructorShouldSetCorrectValues1()
        {
            //Half circle left to right, clockwise
            string path = "A32,32 0 0,1 74,20";
            PathCommand sut = new PathCommand(path,10,20);

            Assert.Equal(10, sut.StartX);
            Assert.Equal(20, sut.StartY);
            Assert.Equal(74, sut.EndX);
            Assert.Equal(20, sut.EndY);
            Assert.Equal(42, sut.CenterX);
            Assert.Equal(20, sut.CenterY);
            Assert.Equal(32, sut.RadiusX);
            Assert.Equal(32, sut.RadiusY);
        }
Esempio n. 9
0
 public void MPathCommandTest_()
 {
     string svgPath1 = "M18,24";
     string svgPath2 = "m18,24";
     PathCommand command1 = new PathCommand(svgPath1);
     PathCommand command2 = new PathCommand(svgPath1, 10, 20);
     PathCommand command3 = new PathCommand(svgPath2);
     PathCommand command4 = new PathCommand(svgPath2, 10, 20);
     Assert.True(command1.GetRelativePath() == "m18,24");
     Assert.True(command1.GetAbsolutePath() == "M18,24");
     Assert.True(command2.GetRelativePath() == "m8,4");
     Assert.True(command2.GetAbsolutePath() == "M18,24");
     Assert.True(command3.GetRelativePath() == "m18,24");
     Assert.True(command3.GetAbsolutePath() == "M18,24");
     Assert.True(command4.GetRelativePath() == "m18,24");
     Assert.True(command4.GetAbsolutePath() == "M28,44");
 }
Esempio n. 10
0
 public void APathCommandIsUpperLowerTest()
 {
     PathCommand command1 = new PathCommand("A32,32 0 0,1 64,0");
     PathCommand command2 = new PathCommand("a32,32 0 0,1 64,0");
     PathCommand command3 = new PathCommand("a32,32 0 0,1 -64,0");
     PathCommand command4 = new PathCommand("A32,32 0 1,0 64,0");
     PathCommand command5 = new PathCommand("a32,32 0 1,0 64,0");
     PathCommand command6 = new PathCommand("a32,32 0 1,0 -64,0");
     PathCommand command7 = new PathCommand("a32,32 0 1,0 0,64");
     PathCommand command8 = new PathCommand("a32,32 0 1,0 0,-64");
     Assert.False(command1.IsMoveToCommand());
     Assert.True(command1.IsArcCommand());
     Assert.True(command1.IsUpper());
     Assert.False(command1.IsLower());
     Assert.True(command2.IsUpper());
     Assert.False(command2.IsLower());
     Assert.False(command3.IsUpper());
     Assert.True(command3.IsLower());
     Assert.False(command4.IsUpper());
     Assert.True(command4.IsLower());
     Assert.False(command5.IsUpper());
     Assert.True(command5.IsLower());
     Assert.True(command6.IsUpper());
     Assert.False(command6.IsLower());
     Assert.True(command7.IsUpper());
     Assert.True(command7.IsLower());
     Assert.True(command8.IsUpper());
     Assert.True(command8.IsLower());
 }
Esempio n. 11
0
        public void APathCommandIsCircularVerticalHorizontalTest()
        {
            //line in the shape of a lower half circle, clockwise from left to right, horizontal (line between start y and end y) 
            PathCommand command1 = new PathCommand("a32,32 0 0,1 64,0");
            //like above, but elliptic with half the radius.
            PathCommand command2 = new PathCommand("a32,16 0 0,1 64,0");
            //line in the shape of a right half ellipse (half radius compared to circle), counter-clockwise from top to bottom, vertical (line between start x and end x)
            PathCommand command3 = new PathCommand("a32,16 0 1,0 0,64");
            //like above but a right half circle
            PathCommand command4 = new PathCommand("a32,32 0 1,0 0,64");

            Assert.True(command1.IsCircular());
            Assert.False(command2.IsCircular());
            Assert.False(command3.IsCircular());
            Assert.True(command4.IsCircular());
            Assert.True(command1.IsHorizontal());
            Assert.True(command2.IsHorizontal());
            Assert.False(command3.IsHorizontal());
            Assert.False(command4.IsHorizontal());
            Assert.False(command1.IsVertical());
            Assert.False(command2.IsVertical());
            Assert.True(command3.IsVertical());
            Assert.True(command4.IsVertical());
        }
Esempio n. 12
0
 public void APathCommandIsRightLeftTest()
 {
     PathCommand command1 = new PathCommand("A32,32 0 0,1 0,64");
     PathCommand command2 = new PathCommand("a32,32 0 0,1 0,64");
     PathCommand command3 = new PathCommand("a32,32 0 0,1 0,-64");
     PathCommand command4 = new PathCommand("A32,32 0 1,0 0,64");
     PathCommand command5 = new PathCommand("a32,32 0 1,0 0,64");
     PathCommand command6 = new PathCommand("a32,32 0 1,0 0,-64");
     PathCommand command7 = new PathCommand("a32,32 0 1,0 64,0");
     PathCommand command8 = new PathCommand("a32,32 0 1,0 -64,0");
     Assert.True(command1.IsRight());
     Assert.False(command1.IsLeft());
     Assert.True(command2.IsRight());
     Assert.False(command2.IsLeft());
     Assert.False(command3.IsRight());
     Assert.True(command3.IsLeft());
     Assert.False(command4.IsRight());
     Assert.True(command4.IsLeft());
     Assert.False(command5.IsRight());
     Assert.True(command5.IsLeft());
     Assert.True(command6.IsRight());
     Assert.False(command6.IsLeft());
     Assert.True(command7.IsRight());
     Assert.True(command8.IsLeft());
     Assert.True(command7.IsRight());
     Assert.True(command8.IsLeft());
 }
Esempio n. 13
0
        public void ConstructorShouldSetCorrectValues20()
        {
            //Quarter circle, vertical, lower to upper, counter-clockwise
            float radius = (float)(Math.Sqrt(2) * 32);
            string path = "a" + radius + "," + radius + " 0 0,0 0,-32";
            PathCommand sut = new PathCommand(path, 10, 20);

            Assert.Equal(-6, sut.CenterX);
            Assert.Equal(4, sut.CenterY);
        }
Esempio n. 14
0
        public void ConstructorShouldSetCorrectValues16()
        {
            //Quarter circle, horizontal, right to left, counter-clockwise
            float radius = (float)(Math.Sqrt(2) * 32);
            string path = "a" + radius + "," + radius + " 0 0,0 -32,0";
            PathCommand sut = new PathCommand(path, 10, 20);

            Assert.Equal(-6, sut.CenterX);
            Assert.Equal(36, sut.CenterY);
        }
Esempio n. 15
0
        public void ConstructorShouldSetCorrectValues12()
        {
            //Quarter circle lower left to upper right, counter-clockwise
            string path = "a32,32 0 0,0 32,-32";
            PathCommand sut = new PathCommand(path, 10, 20);

            Assert.Equal(42, sut.CenterX);
            Assert.Equal(20, sut.CenterY);
        }
Esempio n. 16
0
        public void ConstructorShouldSetCorrectValues7()
        {
            //Quarter circle upper right to lower left, clockwise
            string path = "a32,32 0 0,1 -32,32";
            PathCommand sut = new PathCommand(path, 10, 20);

            Assert.Equal(-22, sut.CenterX);
            Assert.Equal(20, sut.CenterY);
        }
Esempio n. 17
0
 protected Shape CreateShape(PathCommand c)
 {
     Shape shape = null;
     if (c.IsMoveToCommand())
     {
         //
     }
     else if (c.IsArcCommand())
     {
         if (c.IsCircular())
         {
             if (c.IsHorizontal())
             {
                 if (c.IsLower())
                 {
                     shape = new LowerHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusX);
                 }
                 else if (c.IsUpper())
                 {
                     shape = new UpperHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusX);
                 }
             }
             else
             if (c.IsVertical())
             {
                 if (c.IsLeft())
                 {
                     shape = new LeftHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusY);
                 }
                 else if (c.IsRight())
                 {
                     shape = new RightHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusY);
                 }
             }
         }
     }
     return shape;
 }
Esempio n. 18
0
 protected void CreatePathCommands(string[] paths)
 {
     float startX = 0;
     float startY = 0;
     for (int i = 0; i < paths.Length; i++)
     {
         PathCommand command = new PathCommand(paths[i], startX, startY);
         startX = command.EndX;
         startY = command.EndY;
         pathCommands.Add(command);
     }
 }