public void LocalCurrency_EnsureLocalCurrencyTypeKindIsCorrect1()
        {
            // arrange
            var type = new LocalCurrencyType();

            // act
            TypeKind kind = type.Kind;

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

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

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

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

            // assert
            Assert.Equal(typeof(NullValueNode), result.GetType());
        }
        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);
        }
        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);
        }
        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);
        }
        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());
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }