Beispiel #1
0
        public void Parse_Degrees_With_Comma_Decimal_Separator_Not_Allowed_To_Use_Comma_As_Separator()
        {
            var location = "-41,95,12,45";

            Action action = () => GpsLocation.Parse(location, CultureInfo.GetCultureInfo(1043));

            action.Should().Throw <ArgumentException>();
        }
Beispiel #2
0
        public void IF_string_is_invalid_SHOULD_fail(string serializedLocation)
        {
            //Act
            var result = GpsLocation.Parse(serializedLocation);

            //Assert
            Assert.That(result.IsFailure);
        }
Beispiel #3
0
        public void Parse_Degrees_With_Semicolon_Separator()
        {
            var location = "-41.95;12.45";

            var sut = GpsLocation.Parse(location);

            sut.Latitude.Should().BeInRange(-42.0, -41.9);
            sut.Longitude.Should().BeInRange(12.4, 12.5);
        }
Beispiel #4
0
        public void Parse_Degrees_With_Comma_Decimal_Separator()
        {
            var location = "-41,95 12,45";

            var sut = GpsLocation.Parse(location, CultureInfo.GetCultureInfo(1043));

            sut.Latitude.Should().BeInRange(-42.0, -41.9);
            sut.Longitude.Should().BeInRange(12.4, 12.5);
        }
Beispiel #5
0
        public void Parse_Degrees_With_Minus_Sign_To_GpsLocation()
        {
            var location = "-41.95 12.45";

            var sut = GpsLocation.Parse(location);

            sut.Latitude.Should().BeInRange(-42.0, -41.9);
            sut.Longitude.Should().BeInRange(12.4, 12.5);
        }
Beispiel #6
0
        public void Parse_Degrees_With_Spaces_To_GpsLocation()
        {
            var location = "41.95° N 12.45° E";

            var sut = GpsLocation.Parse(location);

            sut.Latitude.Should().BeInRange(41.9, 42.0);
            sut.Longitude.Should().BeInRange(12.4, 12.5);
        }
Beispiel #7
0
        public void Parse_Degree_Minutes_Without_Spaces_To_GpsLocation()
        {
            var location = "41°54.5'N 12°29.5'E";

            var sut = GpsLocation.Parse(location);

            sut.Latitude.Should().BeInRange(41.9, 42.0);
            sut.Longitude.Should().BeInRange(12.4, 12.5);
        }
Beispiel #8
0
        public void Parse_Degree_Minutes_Seconds_With_Spaces_To_GpsLocation()
        {
            var location = "41° 54' 10.0\" N 12° 29' 38.8\" E";

            var sut = GpsLocation.Parse(location);

            sut.Latitude.Should().BeInRange(41.9, 42.0);
            sut.Longitude.Should().BeInRange(12.4, 12.5);
        }
Beispiel #9
0
        public void SHOULD_parse_valid_string(string parsedGpsLocation, double latitude, double longitude)
        {
            //Act
            var result = GpsLocation.Parse(parsedGpsLocation);

            //Assert
            Assert.That(result.IsSuccess);
            Assert.That(result.Value.Latitude, Is.EqualTo(latitude));
            Assert.That(result.Value.Longitude, Is.EqualTo(longitude));
        }
Beispiel #10
0
        public void SHOULD_parse_using_invariant_culture()
        {
            //Arrange
            var currentCulture = Thread.CurrentThread.CurrentCulture;
            var gpsString      = 10.11212d + "," + 10.11212d;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("de");

            //Act
            var result = GpsLocation.Parse(gpsString);

            //Assert
            Assert.That(result.IsSuccess);
            Assert.That(result.Value.Latitude, Is.EqualTo(10.11212d));
            Assert.That(result.Value.Longitude, Is.EqualTo(10.11212d));
            Thread.CurrentThread.CurrentCulture = currentCulture;
        }
Beispiel #11
0
        public void Parse_Invalid_String_Throws_ArgumentOutOfRangeException()
        {
            Action action = () => GpsLocation.Parse("abc");

            action.Should().Throw <ArgumentOutOfRangeException>();
        }
Beispiel #12
0
        public void Parse_Empty_String_Throws_ArgumentOutOfRangeException()
        {
            Action action = () => GpsLocation.Parse(string.Empty);

            action.Should().Throw <ArgumentOutOfRangeException>();
        }
Beispiel #13
0
        public void Parse_Null_Throws_ArgumentNullException()
        {
            Action action = () => GpsLocation.Parse(null);

            action.Should().Throw <ArgumentNullException>();
        }