コード例 #1
0
        protected void LocalTime_ExpectParseLiteralToThrowSerializationException()
        {
            // arrange
            ScalarType scalar      = CreateType <LocalTimeType>();
            var        valueSyntax = new StringValueNode("foo");

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
        protected void LocalCurrency_ExpectParseLiteralToMatch()
        {
            // arrange
            ScalarType    scalar         = CreateType <LocalCurrencyType>();
            var           valueSyntax    = new StringValueNode("$24.99");
            const decimal expectedResult = 24.99m;

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

            // assert
            Assert.Equal(expectedResult, result);
        }
コード例 #7
0
        protected void ExpectParseLiteralToMatch <TType>(
            IValueNode valueSyntax,
            object?expectedResult)
            where TType : ScalarType
        {
            // arrange
            ScalarType scalar = CreateType <TType>();

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

            // assert
            Assert.Equal(expectedResult, result);
        }