Skip to content

Commit b2bfdff

Browse files
authored
Added tests that show CompareTo is ignore. (#6245)
1 parent bc9a5ba commit b2bfdff

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

src/HotChocolate/Core/test/Types.Tests/CodeFirstTests.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ public async Task Structural_Equality_Is_Ignored()
149149
schema.MatchSnapshot();
150150
}
151151

152+
[Fact]
153+
public async Task Comparison_Is_Ignored()
154+
{
155+
var schema =
156+
await new ServiceCollection()
157+
.AddGraphQL()
158+
.AddQueryType<QueryComparableEntity>()
159+
.BuildSchemaAsync();
160+
161+
schema.MatchSnapshot();
162+
}
152163

153164
[Fact]
154165
public async Task Allow_PascalCasedArguments_Schema()
@@ -320,10 +331,10 @@ public interface IBar
320331

321332
public class QueryStructEquals
322333
{
323-
public Example Foo(Example example) => example;
334+
public EquatableExample Foo(EquatableExample example) => example;
324335
}
325336

326-
public class Example : IStructuralEquatable
337+
public class EquatableExample : IStructuralEquatable
327338
{
328339
public string Some { get; set; } = default!;
329340

@@ -332,6 +343,26 @@ public class Example : IStructuralEquatable
332343
public int GetHashCode(IEqualityComparer comparer) => throw new NotImplementedException();
333344
}
334345

346+
public class QueryComparableEntity
347+
{
348+
public ComparableExample Foo(ComparableExample example) => example;
349+
}
350+
351+
public class ComparableExample : IComparable, IComparable<EquatableExample>
352+
{
353+
public string Some { get; set; } = default!;
354+
355+
public int CompareTo(object? obj)
356+
{
357+
throw new NotImplementedException();
358+
}
359+
360+
public int CompareTo(EquatableExample? other)
361+
{
362+
throw new NotImplementedException();
363+
}
364+
}
365+
335366
public class PascalCaseQuery
336367
{
337368
public string TestResolver(string TestArgument) => "abc";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
schema {
2+
query: QueryComparableEntity
3+
}
4+
5+
type ComparableExample {
6+
some: String!
7+
}
8+
9+
type QueryComparableEntity {
10+
foo(example: ComparableExampleInput!): ComparableExample!
11+
}
12+
13+
input ComparableExampleInput {
14+
some: String!
15+
}

src/HotChocolate/Core/test/Types.Tests/__snapshots__/CodeFirstTests.Structural_Equality_Is_Ignored.graphql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ schema {
22
query: QueryStructEquals
33
}
44

5-
type Example {
5+
type EquatableExample {
66
some: String!
77
}
88

99
type QueryStructEquals {
10-
foo(example: ExampleInput!): Example!
10+
foo(example: EquatableExampleInput!): EquatableExample!
1111
}
1212

13-
input ExampleInput {
13+
input EquatableExampleInput {
1414
some: String!
1515
}

0 commit comments

Comments
 (0)