Пример #1
0
        protected void Latitude_ExpectParseResultToMatchNull()
        {
            // arrange
            ScalarType scalar      = new LatitudeType();
            object     valueSyntax = null !;

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

            // assert
            Assert.Equal(typeof(NullValueNode), result.GetType());
        }
Пример #2
0
        Latitude_ExpectDeserializeStringToThrowSerializationException_GreaterThanMax()
        {
            // arrange
            ScalarType   scalar      = new LatitudeType();
            const string?valueSyntax = "92° 0' 0.000\" N" !;

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #3
0
        protected void Latitude_ExpectSerializeDoubleToThrowSerializationException_GreaterThanMax()
        {
            // arrange
            ScalarType   scalar      = new LatitudeType();
            const double valueSyntax = 91d;

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #4
0
        protected void Latitude_ExpectSerializeIntToThrowSerializationException_LessThanMin()
        {
            // arrange
            ScalarType scalar      = new LatitudeType();
            const int  valueSyntax = -91;

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #5
0
        protected void Latitude_ExpectParseResultToThrowOnInvalidType()
        {
            // arrange
            ScalarType scalar      = new LatitudeType();
            const char valueSyntax = 'c';

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #6
0
        protected void Latitude_ExpectParseResultToMatchDouble()
        {
            // arrange
            ScalarType   scalar      = new LatitudeType();
            const double valueSyntax = 89d;

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

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Пример #7
0
        protected void Latitude_ExpectParseResultToThrowOnInvalidString()
        {
            // arrange
            ScalarType scalar      = new LatitudeType();
            var        valueSyntax = "92° 0' 0.000\" S";

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #8
0
        public void Latitude_ExpectSerializeDouble()
        {
            // arrange
            ScalarType   scalar      = new LatitudeType();
            const double valueSyntax = 89d;

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

            // assert
            Assert.True(success);
            Assert.IsType <string>(d);
        }
Пример #9
0
        protected void Latitude_ExpectDeserializeStringToThrowSerializationException_LessThanMin()
        {
            // arrange
            ScalarType   scalar      = new LatitudeType();
            const string valueSyntax = "91° 0' 0.000\" S" !;

            // act

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #10
0
        protected void Latitude_ExpectDeserializeStringToMatch()
        {
            // arrange
            ScalarType   scalar        = new LatitudeType();
            const double expectedValue = -89d;

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

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