Ejemplo n.º 1
0
        public void RoundTripTestStartingFromModelObjects()
        {
            var file1 = new GpxFile();

            file1.Metadata = DataObjectBuilders.RandomGpxMetadata(this.random);
            for (int i = 0, cnt = this.random.Next(5, 10); i < cnt; i++)
            {
                file1.Waypoints.Add(DataObjectBuilders.RandomWaypoint(this.random));
            }

            for (int i = 0, cnt = this.random.Next(5, 10); i < cnt; i++)
            {
                file1.Routes.Add(DataObjectBuilders.RandomRoute(this.random));
            }

            for (int i = 0, cnt = this.random.Next(5, 10); i < cnt; i++)
            {
                file1.Tracks.Add(DataObjectBuilders.RandomTrack(this.random));
            }

            file1.Extensions = DataObjectBuilders.RandomExtensions(this.random);

            var file2 = GpxFile.Parse(file1.BuildString(null), null);

            Assert.Equal(file1.Metadata, file2.Metadata);
            Assert.Equal(file1.Waypoints.AsEnumerable(), file2.Waypoints.AsEnumerable());
            Assert.Equal(file1.Routes.AsEnumerable(), file2.Routes.AsEnumerable());
            Assert.Equal(file1.Tracks.AsEnumerable(), file2.Tracks.AsEnumerable());
            Assert.StrictEqual(file1.Extensions, file2.Extensions);
        }
Ejemplo n.º 2
0
        public void RoundTripForValuesVeryNearZeroShouldSucceed()
        {
            var expectedWaypoint = new GpxWaypoint(new GpxLongitude(0.00001), new GpxLatitude(double.Epsilon), -double.Epsilon);
            var file             = new GpxFile
            {
                Waypoints = { expectedWaypoint },
            };

            file = GpxFile.Parse(file.BuildString(null), null);

            var actualWaypoint = Assert.Single(file.Waypoints);

            Assert.Equal(expectedWaypoint, actualWaypoint);
        }