Exemplo n.º 1
0
        public void Longitude_EnsureLongitudeTypeKindIsCorrect()
        {
            // arrange
            // act
            ScalarType type = new LongitudeType();

            // assert
            Assert.Equal(TypeKind.Scalar, type.Kind);
        }
Exemplo n.º 2
0
        protected void Longitude_ExpectParseResultToMatchNull()
        {
            // arrange
            ScalarType scalar      = new LongitudeType();
            object     valueSyntax = null !;

            // act
            IValueNode result = scalar.ParseResult(valueSyntax);

            // assert
            Assert.Equal(typeof(NullValueNode), result.GetType());
        }
Exemplo n.º 3
0
        protected void Longitude_ExpectSerializeDoubleToThrowSerializationException_GreaterThanMax()
        {
            // arrange
            ScalarType   scalar      = new LongitudeType();
            const double valueSyntax = 181d;

            // act
            Exception?result = Record.Exception(() => scalar.Serialize(valueSyntax));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Exemplo n.º 4
0
        protected void Longitude_ExpectSerializeIntToThrowSerializationException_LessThanMin()
        {
            // arrange
            ScalarType scalar      = new LongitudeType();
            const int  valueSyntax = -181;

            // act
            Exception?result = Record.Exception(() => scalar.Serialize(valueSyntax));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Exemplo n.º 5
0
        Longitude_ExpectDeserializeStringToThrowSerializationException_GreaterThanMax()
        {
            // arrange
            ScalarType   scalar      = new LongitudeType();
            const string?valueSyntax = "182° 0' 0.000\" E" !;

            // act
            Exception?result = Record.Exception(() => scalar.Deserialize(valueSyntax));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Exemplo n.º 6
0
        protected void Longitude_ExpectParseResultToThrowOnInvalidType()
        {
            // arrange
            ScalarType scalar      = new LongitudeType();
            const char valueSyntax = 'c';

            // act
            Exception?result = Record.Exception(() => scalar.ParseResult(valueSyntax));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Exemplo n.º 7
0
        protected void Longitude_ExpectParseResultToMatchDouble()
        {
            // arrange
            ScalarType   scalar      = new LongitudeType();
            const double valueSyntax = 179d;

            // act
            IValueNode result = scalar.ParseResult(valueSyntax);

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Exemplo n.º 8
0
        protected void Longitude_ExpectParseResultToThrowOnInvalidString()
        {
            // arrange
            ScalarType   scalar      = new LongitudeType();
            const string valueSyntax = "-181° 0' 0.000\" W" !;

            // act
            Exception?result = Record.Exception(() => scalar.ParseResult(valueSyntax));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Exemplo n.º 9
0
        public void Longitude_ExpectSerializeDouble()
        {
            // arrange
            ScalarType   scalar      = new LongitudeType();
            const double valueSyntax = 179d;

            // act
            var success = scalar.TrySerialize(valueSyntax, out var d);

            // assert
            Assert.True(success);
            Assert.IsType <string>(d);
        }
Exemplo n.º 10
0
        protected void Longitude_ExpectDeserializeStringToThrowSerializationException_LessThanMin()
        {
            // arrange
            ScalarType   scalar      = new LongitudeType();
            const string valueSyntax = "-181° 0' 0.000\" W" !;

            // act

            Exception?result = Record.Exception(() => scalar.Deserialize(valueSyntax));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Exemplo n.º 11
0
        protected void Longitude_ExpectDeserializeStringToMatch()
        {
            // arrange
            ScalarType   scalar        = new LongitudeType();
            const double expectedValue = -179d;

            // act
            var success = scalar.TryDeserialize("179° 0' 0.000\" W",
                                                out var deserialized);

            // assert
            Assert.True(success);
            Assert.Equal(expectedValue, deserialized);
        }