Skip to content

Commit

Permalink
Added CookieCrumble.TUnit to Fusion-vnext (#7794)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Dec 3, 2024
1 parent df4fbcc commit 3b60abb
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 117 deletions.
9 changes: 9 additions & 0 deletions src/HotChocolate/Fusion-vnext/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<Using Include="CookieCrumble" />
<Using Include="CookieCrumble.TUnit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\CookieCrumble\src\CookieCrumble.TUnit\CookieCrumble.TUnit.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="TUnit" />
</ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Runtime.CompilerServices;

namespace HotChocolate.Fusion;

internal static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize()
{
CookieCrumbleTUnit.Initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace HotChocolate.Fusion;
public class OperationPlannerTests
{
[Test]
public async Task Plan_Simple_Operation_1_Source_Schema()
public void Plan_Simple_Operation_1_Source_Schema()
{
var compositeSchemaDoc = Utf8GraphQLParser.Parse(FileResource.Open("fusion1.graphql"));
var compositeSchema = CompositeSchemaBuilder.Create(compositeSchemaDoc);
Expand All @@ -34,25 +34,11 @@ fragment Product on Product {
var plan = planner.CreatePlan(rewritten, null);

// assert
await Assert
.That(plan.Serialize())
.IsEqualTo(
"""
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "{ productById(id: 1) { id name } }"
}
]
}
""");
plan.Serialize().MatchSnapshot();
}

[Test]
public async Task Plan_Simple_Operation_2_Source_Schema()
public void Plan_Simple_Operation_2_Source_Schema()
{
var compositeSchemaDoc = Utf8GraphQLParser.Parse(FileResource.Open("fusion1.graphql"));
var compositeSchema = CompositeSchemaBuilder.Create(compositeSchemaDoc);
Expand Down Expand Up @@ -80,32 +66,11 @@ fragment Product on Product {
var plan = planner.CreatePlan(rewritten, null);

// assert
await Assert
.That(plan.Serialize())
.IsEqualTo(
"""
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "{ productById(id: 1) { id name } }",
"nodes": [
{
"kind": "Operation",
"schema": "SHIPPING",
"document": "{ productById { estimatedDelivery(postCode: \u002212345\u0022) } }"
}
]
}
]
}
""");
plan.Serialize().MatchSnapshot();
}

[Test]
public async Task Plan_Simple_Operation_3_Source_Schema()
public void Plan_Simple_Operation_3_Source_Schema()
{
var compositeSchemaDoc = Utf8GraphQLParser.Parse(FileResource.Open("fusion1.graphql"));
var compositeSchema = CompositeSchemaBuilder.Create(compositeSchemaDoc);
Expand Down Expand Up @@ -148,39 +113,11 @@ fragment AuthorCard on UserProfile {
var plan = planner.CreatePlan(rewritten, null);

// assert
await Assert
.That(plan.Serialize())
.IsEqualTo(
"""
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "{ productById(id: 1) { name } }",
"nodes": [
{
"kind": "Operation",
"schema": "REVIEWS",
"document": "{ productById { reviews(first: 10) { nodes { body stars author } } } }",
"nodes": [
{
"kind": "Operation",
"schema": "ACCOUNTS",
"document": "{ userById { displayName } }"
}
]
}
]
}
]
}
""");
plan.Serialize().MatchSnapshot();
}

[Test]
public async Task Plan_Simple_Operation_3_Source_Schema_And_Single_Variable()
public void Plan_Simple_Operation_3_Source_Schema_And_Single_Variable()
{
var compositeSchemaDoc = Utf8GraphQLParser.Parse(FileResource.Open("fusion1.graphql"));
var compositeSchema = CompositeSchemaBuilder.Create(compositeSchemaDoc);
Expand Down Expand Up @@ -223,34 +160,6 @@ fragment AuthorCard on UserProfile {
var plan = planner.CreatePlan(rewritten, null);

// assert
await Assert
.That(plan.Serialize())
.IsEqualTo(
"""
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "query($id: ID!) { productById(id: $id) { name } }",
"nodes": [
{
"kind": "Operation",
"schema": "REVIEWS",
"document": "query($first: Int! = 10) { productById { reviews(first: $first) { nodes { body stars author } } } }",
"nodes": [
{
"kind": "Operation",
"schema": "ACCOUNTS",
"document": "{ userById { displayName } }"
}
]
}
]
}
]
}
""");
plan.Serialize().MatchSnapshot();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "{ productById(id: 1) { id name } }"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "{ productById(id: 1) { id name } }",
"nodes": [
{
"kind": "Operation",
"schema": "SHIPPING",
"document": "{ productById { estimatedDelivery(postCode: \u002212345\u0022) } }"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "{ productById(id: 1) { name } }",
"nodes": [
{
"kind": "Operation",
"schema": "REVIEWS",
"document": "{ productById { reviews(first: 10) { nodes { body stars author } } } }",
"nodes": [
{
"kind": "Operation",
"schema": "ACCOUNTS",
"document": "{ userById { displayName } }"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"kind": "Root",
"nodes": [
{
"kind": "Operation",
"schema": "PRODUCTS",
"document": "query($id: ID!) { productById(id: $id) { name } }",
"nodes": [
{
"kind": "Operation",
"schema": "REVIEWS",
"document": "query($first: Int! = 10) { productById { reviews(first: $first) { nodes { body stars author } } } }",
"nodes": [
{
"kind": "Operation",
"schema": "ACCOUNTS",
"document": "{ userById { displayName } }"
}
]
}
]
}
]
}

This file was deleted.

0 comments on commit 3b60abb

Please sign in to comment.