Ejemplo n.º 1
0
        public void LocalCurrency_EnsureLocalCurrencyTypeKindIsCorrect1()
        {
            // arrange
            var type = new LocalCurrencyType();

            // act
            TypeKind kind = type.Kind;

            // assert
            Assert.Equal(TypeKind.Scalar, kind);
        }
Ejemplo n.º 2
0
        public void LocalCurrency_ExpectDeserializeInvalidStringToDecimal()
        {
            // arrange
            ScalarType scalar = new LocalCurrencyType();

            // act
            var success = scalar.TryDeserialize("abc", out object?_);

            // assert
            Assert.False(success);
        }
Ejemplo n.º 3
0
        protected void LocalCurrency_ExpectParseResultToMatchNull()
        {
            // arrange
            ScalarType scalar = new LocalCurrencyType();

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

            // assert
            Assert.Equal(typeof(NullValueNode), result.GetType());
        }
Ejemplo n.º 4
0
        protected void LocalCurrency_ExpectIsStringValueToNotMatchEuro()
        {
            // arrange
            ScalarType scalar      = new LocalCurrencyType("Germany", "de-De");
            var        valueSyntax = new StringValueNode("$10.99");

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Ejemplo n.º 5
0
        protected void LocalCurrency_ExpectIsStringValueToMatchEuro()
        {
            // arrange
            ScalarType scalar      = new LocalCurrencyType("Germany", "de-De");
            var        valueSyntax = new StringValueNode("10,99 €");

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

            // assert
            Assert.True(result);
        }
Ejemplo n.º 6
0
        protected void LocalCurrency_ExpectParseResultToThrowSerializationException()
        {
            // arrange
            ScalarType scalar       = new LocalCurrencyType();
            IValueNode runtimeValue = new IntValueNode(1);

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

            // assert
            Assert.IsType <SerializationException>(result);
        }
Ejemplo n.º 7
0
        protected void LocalCurrency_ExpectParseResultToMatchStringValue()
        {
            // arrange
            ScalarType   scalar      = new LocalCurrencyType();
            const string valueSyntax = "$9.99";

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

            // assert
            Assert.Equal(typeof(StringValueNode), result.GetType());
        }
Ejemplo n.º 8
0
        public void LocalCurrency_ExpectDeserializeNullToNull()
        {
            // arrange
            ScalarType scalar = new LocalCurrencyType();

            // act
            var success = scalar.TryDeserialize(null, out object?deserialized);

            // assert
            Assert.True(success);
            Assert.Null(deserialized);
        }
Ejemplo n.º 9
0
        public void LocalCurrency_ExpectDeserializeNullableDecimalToDecimal()
        {
            // arrange
            ScalarType scalar       = new LocalCurrencyType();
            decimal?   runtimeValue = null;

            // act
            var success = scalar.TryDeserialize(runtimeValue, out object?deserialized);

            // assert
            Assert.True(success);
            Assert.Null(deserialized);
        }
Ejemplo n.º 10
0
        protected void LocalCurrency_ExpectSerializeDecimalToMatch()
        {
            // arrange
            ScalarType    scalar        = new LocalCurrencyType();
            const decimal runtimeValue  = 9.99m;
            const string  expectedValue = "$9.99";

            // act
            string serializedValue = (string)scalar.Serialize(runtimeValue) !;

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }
Ejemplo n.º 11
0
        public void LocalCurrency_ParseLiteralStringValueDifferentCulture(string name, string cultureName)
        {
            // arrange
            ScalarType    scalar          = new LocalCurrencyType(name, cultureName);
            var           valueSyntax     = new StringValueNode("9.99");
            const decimal expectedDecimal = 9.99m;

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

            // assert
            Assert.Equal(expectedDecimal, result);
        }
Ejemplo n.º 12
0
        protected void LocalCurrency_ExpectParseLiteralToMatchEuro()
        {
            // arrange
            ScalarType    scalar         = new LocalCurrencyType("Germany", "de-DE");
            var           valueSyntax    = new StringValueNode("24,99 €");
            const decimal expectedResult = 24.99m;

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

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