34 references to new
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatResponseFormat.cs (2)
28public static ChatResponseFormatJson Json { get; } = new(schema: null); 37new(Throw.IfNull(schema),
Microsoft.Extensions.AI.Abstractions.Tests (32)
ChatCompletion\ChatResponseFormatTests.cs (32)
22Assert.Throws<ArgumentException>("schemaName", () => new ChatResponseFormatJson(null, "name")); 23Assert.Throws<ArgumentException>("schemaDescription", () => new ChatResponseFormatJson(null, null, "description")); 24Assert.Throws<ArgumentException>("schemaName", () => new ChatResponseFormatJson(null, "name", "description")); 30ChatResponseFormatJson f = new(null); 39ChatResponseFormatJson f = new("{}", "name", "description"); 52Assert.False(ChatResponseFormat.Text.Equals(new ChatResponseFormatJson(null))); 53Assert.False(ChatResponseFormat.Text.Equals(new ChatResponseFormatJson("{}"))); 58Assert.False(ChatResponseFormat.Json.Equals(new ChatResponseFormatJson("{}"))); 60Assert.True(ChatResponseFormat.Json.Equals(new ChatResponseFormatJson(null))); 61Assert.Equal(ChatResponseFormat.Json.GetHashCode(), new ChatResponseFormatJson(null).GetHashCode()); 63Assert.True(new ChatResponseFormatJson("{}").Equals(new ChatResponseFormatJson("{}"))); 64Assert.Equal(new ChatResponseFormatJson("{}").GetHashCode(), new ChatResponseFormatJson("{}").GetHashCode()); 66Assert.False(new ChatResponseFormatJson("""{ "prop": 42 }""").Equals(new ChatResponseFormatJson("""{ "prop": 43 }"""))); 67Assert.NotEqual(new ChatResponseFormatJson("""{ "prop": 42 }""").GetHashCode(), new ChatResponseFormatJson("""{ "prop": 43 }""").GetHashCode()); // technically not guaranteed 69Assert.False(new ChatResponseFormatJson("""{ "prop": 42 }""").Equals(new ChatResponseFormatJson("""{ "PROP": 42 }"""))); 70Assert.NotEqual(new ChatResponseFormatJson("""{ "prop": 42 }""").GetHashCode(), new ChatResponseFormatJson("""{ "PROP": 42 }""").GetHashCode()); // technically not guaranteed 72Assert.True(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name", "description"))); 73Assert.False(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name", "description2"))); 74Assert.False(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name2", "description"))); 75Assert.False(new ChatResponseFormatJson("{}", "name", "description").Equals(new ChatResponseFormatJson("{}", "name2", "description2"))); 77Assert.Equal(new ChatResponseFormatJson("{}", "name", "description").GetHashCode(), new ChatResponseFormatJson("{}", "name", "description").GetHashCode());