public async Task NullableWithValue_Enabled()
        {
            tester.AddQuery("./Files/NullableReferenceTypes/NullableWithValue.gql");
            tester.Configure(s =>
            {
                s.TemplateSettings["Nullable"] = "enabled";
            });

            var code = await tester.Generate();

            await tester.Verify();

            Assert.Contains("public Test.DroidResult? Test { get; set; }", code);
            Assert.Contains("Task<Test.NullableWithValueQResult> NullableWithValueQAsync(string? temp);", code);
        }
Beispiel #2
0
        public async Task SettingExplicitlyTrue()
        {
            tester.AddQuery("./Files/StringifiedEnums/Query.gql");
            tester.Configure(s =>
            {
                s.TemplateSettings["StringifyEnums"] = "true";
            });

            var code = await tester.Generate();

            Assert.Contains(@"[JsonConverter(typeof(Episode.CustomJsonStringifiedEnumConverter))]", code);
            Assert.Contains(@"public class Episode", code);

            await tester.Verify();
        }
Beispiel #3
0
        public async Task NewtonsoftJsonConverter()
        {
            var tester = new CodeGeneratorTester();

            tester.AddQuery("./Files/ToggleJsonConverter/Query.gql");

            tester.Configure(x => x.TemplateSettings.Add("JsonConverter", "Newtonsoft.Json"));
            var code = await tester.Generate();

            Assert.Contains("using Newtonsoft.Json;", code);
            Assert.Contains("[JsonProperty(\"nullable\")]", code);
        }
Beispiel #4
0
        public async Task SystemTextJsonConverter()
        {
            var tester = new CodeGeneratorTester();

            tester.AddQuery("./Files/ToggleJsonConverter/Query.gql");

            tester.Configure(x => x.TemplateSettings.Add("JsonConverter", "System.Text.Json"));
            var code = await tester.Generate();

            Assert.DoesNotContain("using Newtonsoft.Json;", code);
            Assert.DoesNotContain("[JsonProperty(\"nullable\")]", code);

            Assert.Contains("using System.Text.Json;", code);
            Assert.Contains("[System.Text.Json.Serialization.JsonPropertyName(\"nullable\")]", code);
        }
Beispiel #5
0
        public async Task NewtonsoftJsonConverter_Executes()
        {
            var tester = new CodeGeneratorTester();

            tester.AddQuery("./Files/ToggleJsonConverter/Query.gql");

            tester.Configure(x => x.TemplateSettings.Add("JsonConverter", "Newtonsoft.Json"));
            tester.ConfigureResponse(q => {
                return(new {
                    nullable = (string)null,
                    nonnullable = "EMPIRE"
                });
            });
            var code = await tester.Generate();

            var result = await tester.ExecuteClient();
        }