Skip to content

Commit

Permalink
Added tests that show CompareTo is ignore. (#6245)
Browse files Browse the repository at this point in the history
  • Loading branch information
shtannikov authored Jun 5, 2023
1 parent bc9a5ba commit b2bfdff
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
35 changes: 33 additions & 2 deletions src/HotChocolate/Core/test/Types.Tests/CodeFirstTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ public async Task Structural_Equality_Is_Ignored()
schema.MatchSnapshot();
}

[Fact]
public async Task Comparison_Is_Ignored()
{
var schema =
await new ServiceCollection()
.AddGraphQL()
.AddQueryType<QueryComparableEntity>()
.BuildSchemaAsync();

schema.MatchSnapshot();
}

[Fact]
public async Task Allow_PascalCasedArguments_Schema()
Expand Down Expand Up @@ -320,10 +331,10 @@ public interface IBar

public class QueryStructEquals
{
public Example Foo(Example example) => example;
public EquatableExample Foo(EquatableExample example) => example;
}

public class Example : IStructuralEquatable
public class EquatableExample : IStructuralEquatable
{
public string Some { get; set; } = default!;

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

public class QueryComparableEntity
{
public ComparableExample Foo(ComparableExample example) => example;
}

public class ComparableExample : IComparable, IComparable<EquatableExample>
{
public string Some { get; set; } = default!;

public int CompareTo(object? obj)
{
throw new NotImplementedException();
}

public int CompareTo(EquatableExample? other)
{
throw new NotImplementedException();
}
}

public class PascalCaseQuery
{
public string TestResolver(string TestArgument) => "abc";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schema {
query: QueryComparableEntity
}

type ComparableExample {
some: String!
}

type QueryComparableEntity {
foo(example: ComparableExampleInput!): ComparableExample!
}

input ComparableExampleInput {
some: String!
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ schema {
query: QueryStructEquals
}

type Example {
type EquatableExample {
some: String!
}

type QueryStructEquals {
foo(example: ExampleInput!): Example!
foo(example: EquatableExampleInput!): EquatableExample!
}

input ExampleInput {
input EquatableExampleInput {
some: String!
}

0 comments on commit b2bfdff

Please sign in to comment.