Ejemplo n.º 1
0
        public void Path_Roundtrip()
        {
            // Arrange
            var path = Substitute.For <IPath>();
            var sut = new PathDtoToPath
                      {
                          Path = path
                      };

            // Act
            // Assert
            Assert.AreEqual(path,
                            sut.Path);
        }
Ejemplo n.º 2
0
        public void Dto_Roundtrip()
        {
            // Arrange
            PathDto dto = CreatePathDto();
            var sut = new PathDtoToPath
                      {
                          Dto = dto
                      };

            // Act
            // Assert
            Assert.AreEqual(dto,
                            sut.Dto);
        }
Ejemplo n.º 3
0
        public void FunctionUnderTest_ExpectedResult_UnderCondition()
        {
            // Arrange
            PointDto dto = CreatePointDto();
            var sut = new PathDtoToPath();

            // Act
            Point actual = sut.CreatePointFromPointDto(dto);

            // Assert
            Assert.True(Math.Abs(1.0 - actual.X) < Tolerance,
                        "X");
            Assert.True(Math.Abs(2.0 - actual.Y) < Tolerance,
                        "Y");
        }
Ejemplo n.º 4
0
        public void CreateTurnDirectionFromString_ReturnsClockwise_ForClockwise()
        {
            // Arrange
            var sut = new PathDtoToPath();

            // Act
            Constants.TurnDirection actual = sut.CreateTurnDirectionFromString("Clockwise");

            // Assert
            Assert.AreEqual(Constants.TurnDirection.Clockwise,
                            actual);
        }
Ejemplo n.º 5
0
        public void CreateTurnDirectionFromString_Throws_ForUnknownString()
        {
            // Arrange
            var sut = new PathDtoToPath();

            // Act
            // Assert
            Assert.Throws <ArgumentException>(() => sut.CreateTurnDirectionFromString("abc"));
        }
Ejemplo n.º 6
0
        public void CreatePolylineSegmentFromDto_ReturnsPolylineSegment_ForArcSegmentDtoFinish()
        {
            // Arrange
            ICircle expectedCircle = CreateExpectedCircle();
            var expectedStartPoint = new Point(1.0,
                                               5.0);
            var expectedEndPoint = new Point(1.0,
                                             -1.0);
            ArcSegmentDto dto = CreateArcSegmentDto();
            var sut = new PathDtoToPath();

            // Act
            var actual = sut.CreatePolylineSegmentFromDto(dto,
                                                          Constants.CircleOrigin.Finish)
                         as ITurnCircleArcSegment;

            // Assert
            Assert.NotNull(actual);
            AssertTurnCircleArcSegment(actual,
                                       expectedCircle,
                                       expectedStartPoint,
                                       expectedEndPoint,
                                       Constants.CircleOrigin.Finish);
        }
Ejemplo n.º 7
0
        public void CreatePolylineSegmentFromDto_Throws_ForUnknownDto()
        {
            // Arrange
            var dto = new UnknownDto();
            var sut = new PathDtoToPath();

            // Act
            // Assert
            Assert.Throws <ArgumentException>(() => sut.CreatePolylineSegmentFromDto(dto,
                                                                                     Constants.CircleOrigin.Start));
        }
Ejemplo n.º 8
0
        public void CreatePolyline_SetsLastSegmentAsFinish_ForPolylineDto()
        {
            // Arrange
            PolylineDto dto = CreatePolylineDto();
            var sut = new PathDtoToPath();

            // Act
            var actual = sut.CreatePolyline(dto).Segments.Last() as ITurnCircleArcSegment;

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(Constants.CircleOrigin.Finish,
                            actual.CircleOrigin);
        }
Ejemplo n.º 9
0
        public void CreatePolylineSegmentFromDto_ReturnsLine_ForLineDto()
        {
            // Arrange
            var expected = new Line(0,
                                    new Point(1.0,
                                              2.0),
                                    new Point(3.0,
                                              4.0),
                                    Constants.LineDirection.Forward);

            LineSegmentDto dto = CreateLineSegmentDto();
            var sut = new PathDtoToPath();

            // Act
            var actual = sut.CreatePolylineSegmentFromDto(dto,
                                                          Constants.CircleOrigin.Start) as ILine;

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expected,
                            actual);
        }
Ejemplo n.º 10
0
        public void CreatePolyline_ReturnsAllSegements_ForPolylineDto()
        {
            // Arrange
            PolylineDto dto = CreatePolylineDto();
            var sut = new PathDtoToPath();

            // Act
            IPolyline actual = sut.CreatePolyline(dto);

            // Assert
            Assert.AreEqual(3,
                            actual.Segments.Count());
        }
Ejemplo n.º 11
0
        public void CreateLineDirectionFromString_ReturnsForward_ForForward()
        {
            // Arrange
            var sut = new PathDtoToPath();

            // Act
            Constants.LineDirection actual = sut.CreateLineDirectionFromString("Forward");

            // Assert
            Assert.AreEqual(Constants.LineDirection.Forward,
                            actual);
        }
Ejemplo n.º 12
0
        public void CreateCircleFormCircleDto_ReturnsCircle_ForDtoIsUnnknownTrue()
        {
            // Arrange
            CircleDto dto = CreateCircleDtoUnknown();
            var sut = new PathDtoToPath();

            // Act
            ICircle actual = sut.CreateCircleFormCircleDto(dto);

            // Assert
            Assert.AreEqual(Circle.Unknown,
                            actual);
        }
Ejemplo n.º 13
0
        public void CreateCircleFormCircleDto_ReturnsCircle_ForDto()
        {
            // Arrange
            ICircle expected = CreateExpectedCircle();
            CircleDto dto = CreateCircleDto();
            var sut = new PathDtoToPath();

            // Act
            ICircle actual = sut.CreateCircleFormCircleDto(dto);

            // Assert
            Assert.AreEqual(expected,
                            actual);
        }
Ejemplo n.º 14
0
        public void Convert_SetsPath_WhenCalled()
        {
            // Arrange
            PathDto dto = CreatePathDto();
            var sut = new PathDtoToPath
                      {
                          Dto = dto
                      };

            // Act
            sut.Convert();

            // Assert
            Assert.AreEqual(3,
                            sut.Path.Segments.Count(),
                            "Count");
        }