Пример #1
0
        protected void LocalCurrency_ParseResult_Null()
        {
            // arrange
            ScalarType scalar = CreateType <LocalCurrencyType>();

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

            // assert
            Assert.Equal(NullValueNode.Default, result);
        }
Пример #2
0
        protected void LocalTime_ExpectSerializeToThrowSerializationException()
        {
            // arrange
            ScalarType scalar = CreateType <LocalTimeType>();

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #3
0
        protected void UtcOffset_ExpectParseLiteralToThrowSerializationException()
        {
            // arrange
            ScalarType scalar      = CreateType <UtcOffsetType>();
            var        valueSyntax = new StringValueNode("+17:00");

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #4
0
        protected void LocalCurrency_ExpectIsStringValueToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalCurrencyType>();
            var        valueSyntax = new StringValueNode("$10.99");

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #5
0
        protected void UtcOffset_ExpectParseValueToMatchTimeSpan()
        {
            // arrange
            ScalarType scalar      = CreateType <UtcOffsetType>();
            var        valueSyntax = new TimeSpan(0, 0, 0);

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

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Пример #6
0
        public void Longitude_ParseLiteral_NullValueNode()
        {
            // arrange
            ScalarType    scalar  = CreateType <LongitudeType>();
            NullValueNode literal = NullValueNode.Default;

            // act
            object value = scalar.ParseLiteral(literal) !;

            // assert
            Assert.Null(value);
        }
Пример #7
0
        protected void LocalCurrency_ExpectParseValueToMatchDecimal()
        {
            // arrange
            ScalarType    scalar      = CreateType <LocalCurrencyType>();
            const decimal valueSyntax = 24.95m;

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

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Пример #8
0
        protected void UtcOffset_ExpectIsUtcOffsetToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <UtcOffsetType>();
            var        valueSyntax = TimeSpan.FromHours(12);

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #9
0
        protected void UtcOffset_ExpectPositiveIsStringValueToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <UtcOffsetType>();
            var        valueSyntax = new StringValueNode("-00:00");

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #10
0
        protected void Longitude_ExpectParseValueToMatch(double runtime, string literal)
        {
            // arrange
            ScalarType      scalar   = CreateType <LongitudeType>();
            StringValueNode expected = new(literal);

            // act
            object result = scalar.ParseValue(runtime);

            // assert
            Assert.Equal(expected, result);
        }
Пример #11
0
        protected void LocalTime_ExpectIsStringValueToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalTimeType>();
            var        valueSyntax = new StringValueNode("2018-06-29T08:46:14+04:00");

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #12
0
        protected void Longitude_ExpectParseValueToMatchType()
        {
            // arrange
            ScalarType   scalar      = CreateType <LongitudeType>();
            const double valueSyntax = 74.3d;

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

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Пример #13
0
        protected void LocalCurrency_ExpectDeserializeStringToMatch()
        {
            // arrange
            ScalarType    scalar       = CreateType <LocalCurrencyType>();
            const decimal runtimeValue = 7.99m;

            // act
            var deserializedValue = (decimal)scalar.Deserialize("$7.99") !;

            // assert
            Assert.Equal(runtimeValue, deserializedValue);
        }
Пример #14
0
        protected void Longitude_ExpectParseLiteralToThrowSerializationException()
        {
            // arrange
            ScalarType      scalar      = CreateType <LongitudeType>();
            StringValueNode valueSyntax = new("foo");

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #15
0
        protected void ExpectParseResultToThrowSerializationException <TType>(object?runtimeValue)
            where TType : ScalarType
        {
            // arrange
            ScalarType scalar = CreateType <TType>();

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #16
0
        protected void LocalTime_ExpectIsDateTimeToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalTimeType>();
            var        valueSyntax = new DateTime(2018, 6, 29, 8, 46, 14);

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #17
0
        protected void Longitude_ExpectIsStringInstanceToMatch()
        {
            // arrange
            ScalarType      scalar      = CreateType <LongitudeType>();
            StringValueNode valueSyntax = new("179° 0' 0.000\" E")!;

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #18
0
        protected void Longitude_ExpectParseValueToThrowSerializationException_LessThanMin()
        {
            // arrange
            ScalarType   scalar       = CreateType <LongitudeType>();
            const double runtimeValue = -181d;

            // act
            Exception?result = Record.Exception(() => scalar.ParseValue(runtimeValue));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #19
0
        protected void LocalTime_ExpectParseValueToThrowSerializationException()
        {
            // arrange
            ScalarType scalar       = CreateType <LocalTimeType>();
            var        runtimeValue = new StringValueNode("foo");

            // act
            Exception?result = Record.Exception(() => scalar.ParseValue(runtimeValue));

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #20
0
        protected void LocalTime_ExpectDeserializeToThrowSerializationException()
        {
            // arrange
            ScalarType scalar       = CreateType <LocalTimeType>();
            object     runtimeValue = new IntValueNode(1);

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #21
0
        protected void LocalTime_ExpectParseValueToMatchDateTime()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalTimeType>();
            var        valueSyntax = new DateTime(2018, 6, 29, 8, 46, 14);

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

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Пример #22
0
        protected void Longitude_ExpectIsDoubleInstanceToFail_GreaterThanMax()
        {
            // arrange
            ScalarType   scalar      = CreateType <LongitudeType>();
            const double valueSyntax = 181d;

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.False(result);
        }
Пример #23
0
        protected void Longitude_ExpectIsDoubleInstanceToMatch()
        {
            // arrange
            ScalarType   scalar      = CreateType <LongitudeType>();
            const double valueSyntax = -179d;

            // act
            var result = scalar.IsInstanceOfType(valueSyntax);

            // assert
            Assert.True(result);
        }
Пример #24
0
        protected void UtcOffset_ExpectParseLiteralToMatch()
        {
            // arrange
            ScalarType scalar         = CreateType <UtcOffsetType>();
            var        valueSyntax    = new StringValueNode("-12:00");
            var        expectedResult = new TimeSpan(-12, 0, 0);

            // act
            object result = (TimeSpan)scalar.ParseLiteral(valueSyntax) !;

            // assert
            Assert.Equal(expectedResult, result);
        }
Пример #25
0
        protected void LocalCurrency_ExpectDeserializeDecimalToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalCurrencyType>();
            object     resultValue = 0.99m;


            // act
            object?result = scalar.Deserialize(resultValue);

            // assert
            Assert.Equal(resultValue, result);
        }
Пример #26
0
        protected void LocalTime_ExpectDeserializeDateTimeToMatch()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalTimeType>();
            object     resultValue = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Utc);


            // act
            object?result = scalar.Deserialize(resultValue);

            // assert
            Assert.Equal(resultValue, result);
        }
Пример #27
0
        protected void ExpectParseLiteralToThrowSerializationException <TType>(
            IValueNode valueSyntax)
            where TType : ScalarType
        {
            // arrange
            ScalarType scalar = CreateType <TType>();

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Пример #28
0
        protected void UtcOffset_ExpectDeserializeTimeSpanToMatch()
        {
            // arrange
            ScalarType scalar       = CreateType <UtcOffsetType>();
            object     resultValue  = new TimeSpan(4, 0, 0);
            object     runtimeValue = new TimeSpan(4, 0, 0);

            // act
            object?result = scalar.Deserialize(resultValue);

            // assert
            Assert.Equal(result, runtimeValue);
        }
Пример #29
0
        protected void LocalTime_ExpectParseLiteralToMatch()
        {
            // arrange
            ScalarType scalar         = CreateType <LocalTimeType>();
            var        valueSyntax    = new StringValueNode("2018-06-29T14:46:14");
            var        expectedResult = new DateTime(2018, 6, 29, 14, 46, 14);

            // act
            object result = (DateTime)scalar.ParseLiteral(valueSyntax) !;

            // assert
            Assert.Equal(expectedResult, result);
        }
Пример #30
0
        protected void UtcOffset_ExpectDeserializeStringToMatch()
        {
            // arrange
            ScalarType scalar       = CreateType <UtcOffsetType>();
            var        runtimeValue = new TimeSpan(4, 0, 0);

            // act
            var deserializedValue = (TimeSpan)scalar
                                    .Deserialize("+04:00") !;

            // assert
            Assert.Equal(runtimeValue, deserializedValue);
        }