JsonSchemaExporter\TestTypes.cs (88)
46yield return new TestData<object>(
51yield return new TestData<bool>(true, """{"type":"boolean"}""");
52yield return new TestData<byte>(42, """{"type":"integer"}""");
53yield return new TestData<ushort>(42, """{"type":"integer"}""");
54yield return new TestData<uint>(42, """{"type":"integer"}""");
55yield return new TestData<ulong>(42, """{"type":"integer"}""");
56yield return new TestData<sbyte>(42, """{"type":"integer"}""");
57yield return new TestData<short>(42, """{"type":"integer"}""");
58yield return new TestData<int>(42, """{"type":"integer"}""");
59yield return new TestData<long>(42, """{"type":"integer"}""");
60yield return new TestData<float>(1.2f, """{"type":"number"}""");
61yield return new TestData<double>(3.14159d, """{"type":"number"}""");
62yield return new TestData<decimal>(3.14159M, """{"type":"number"}""");
70yield return new TestData<string>("I am a string", """{"type":["string","null"]}""");
71yield return new TestData<char>('c', """{"type":"string","minLength":1,"maxLength":1}""");
72yield return new TestData<byte[]>(
77yield return new TestData<Memory<byte>>(new byte[] { 1, 2, 3 }, """{"type":"string"}""");
78yield return new TestData<ReadOnlyMemory<byte>>(new byte[] { 1, 2, 3 }, """{"type":"string"}""");
79yield return new TestData<DateTime>(
84yield return new TestData<DateTimeOffset>(
89yield return new TestData<TimeSpan>(
98yield return new TestData<Guid>(Guid.Empty, """{"type":"string","format":"uuid"}""");
99yield return new TestData<Uri>(new("http://example.com"), """{"type":["string","null"], "format":"uri"}""");
100yield return new TestData<Version>(new(1, 2, 3, 4), """{"$comment":"Represents a version string.", "type":["string","null"],"pattern":"^\\d+(\\.\\d+){1,3}$"}""");
101yield return new TestData<JsonDocument>(JsonDocument.Parse("""[{ "x" : 42 }]"""), "true");
102yield return new TestData<JsonElement>(JsonDocument.Parse("""[{ "x" : 42 }]""").RootElement, "true");
103yield return new TestData<JsonNode>(JsonNode.Parse("""[{ "x" : 42 }]"""), "true");
104yield return new TestData<JsonValue>((JsonValue)42, "true");
105yield return new TestData<JsonObject>(new() { ["x"] = 42 }, """{"type":["object","null"]}""");
106yield return new TestData<JsonArray>([(JsonNode)1, (JsonNode)2, (JsonNode)3], """{"type":["array","null"]}""");
109yield return new TestData<IntEnum>(IntEnum.A, """{"type":"integer"}""");
110yield return new TestData<StringEnum>(StringEnum.A, """{"enum": ["A","B","C"]}""");
111yield return new TestData<FlagsStringEnum>(FlagsStringEnum.A, """{"type":"string"}""");
114yield return new TestData<bool?>(true, """{"type":["boolean","null"]}""");
115yield return new TestData<int?>(42, """{"type":["integer","null"]}""");
116yield return new TestData<double?>(3.14, """{"type":["number","null"]}""");
117yield return new TestData<Guid?>(Guid.Empty, """{"type":["string","null"],"format":"uuid"}""");
118yield return new TestData<JsonElement?>(JsonDocument.Parse("{}").RootElement, "true");
119yield return new TestData<IntEnum?>(IntEnum.A, """{"type":["integer","null"]}""");
120yield return new TestData<StringEnum?>(StringEnum.A, """{"enum":["A","B","C",null]}""");
121yield return new TestData<SimpleRecordStruct?>(
137yield return new TestData<int?>(
143yield return new TestData<DateTimeOffset?>(
151yield return new TestData<SimplePoco>(
187yield return new TestData<SimpleRecord>(
202yield return new TestData<SimpleRecordStruct>(
216yield return new TestData<RecordWithOptionalParameters>(
237yield return new TestData<PocoWithRequiredMembers>(
251yield return new TestData<PocoWithIgnoredMembers>(
261yield return new TestData<PocoWithCustomNaming>(
273yield return new TestData<PocoWithCustomNumberHandling>(
282yield return new TestData<PocoWithCustomNumberHandlingOnProperties>(
307yield return new TestData<PocoWithRecursiveMembers>(
349yield return new TestData<PocoWithNonRecursiveDuplicateOccurrences>(
405yield return new TestData<PocoWithDescription>(
418yield return new TestData<PocoWithCustomConverter>(new() { Value = 42 }, "true");
419yield return new TestData<PocoWithCustomPropertyConverter>(new() { Value = 42 }, """{"type":["object","null"],"properties":{"Value":true}}""");
420yield return new TestData<PocoWithEnums>(
456yield return new TestData<PocoWithStructFollowedByNullableStruct>(
485yield return new TestData<PocoWithNullableStructFollowedByStruct>(
514yield return new TestData<PocoWithExtensionDataProperty>(
518yield return new TestData<PocoDisallowingUnmappedMembers>(
532yield return new TestData<SimplePoco>(
550yield return new TestData<PocoWithNullableAnnotationAttributes>(
565yield return new TestData<PocoWithNullableAnnotationAttributesOnConstructorParams>(
578yield return new TestData<PocoWithNullableConstructorParameter>(
590yield return new TestData<PocoWithOptionalConstructorParams>(
610yield return new TestData<GenericPocoWithNullableConstructorParameter<string>>(
622yield return new TestData<PocoWithPolymorphism>(
678yield return new TestData<NonAbstractClassWithSingleDerivedType>(
688yield return new TestData<ClassWithOptionalObjectParameter>(
701yield return new TestData<PocoCombiningPolymorphicTypeAndDerivedTypes>(
814yield return new TestData<int[]>([1, 2, 3], """{"type":["array","null"],"items":{"type":"integer"}}""");
815yield return new TestData<List<bool>>([false, true, false], """{"type":["array","null"],"items":{"type":"boolean"}}""");
816yield return new TestData<HashSet<string>>(["one", "two", "three"], """{"type":["array","null"],"items":{"type":["string","null"]}}""");
817yield return new TestData<Queue<double>>(new([1.1, 2.2, 3.3]), """{"type":["array","null"],"items":{"type":"number"}}""");
818yield return new TestData<Stack<char>>(new(['x', '2', '+']), """{"type":["array","null"],"items":{"type":"string","minLength":1,"maxLength":1}}""");
819yield return new TestData<ImmutableArray<int>>(ImmutableArray.Create(1, 2, 3), """{"type":"array","items":{"type":"integer"}}""");
820yield return new TestData<ImmutableList<string>>(ImmutableList.Create("one", "two", "three"), """{"type":["array","null"],"items":{"type":["string","null"]}}""");
821yield return new TestData<ImmutableQueue<bool>>(ImmutableQueue.Create(false, false, true), """{"type":["array","null"],"items":{"type":"boolean"}}""");
822yield return new TestData<object[]>([1, "two", 3.14], """{"type":["array","null"]}""");
823yield return new TestData<System.Collections.ArrayList>([1, "two", 3.14], """{"type":["array","null"]}""");
826yield return new TestData<Dictionary<string, int>>(
830yield return new TestData<StructDictionary<string, int>>(
834yield return new TestData<SortedDictionary<int, string>>(
838yield return new TestData<Dictionary<string, SimplePoco>>(
861yield return new TestData<Dictionary<string, object>>(
865yield return new TestData<Hashtable>(