diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 170605a97f9..97799bb54e6 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -14,7 +14,6 @@
-
@@ -54,7 +53,6 @@
-
diff --git a/src/StrawberryShake/Client/test/Core.Tests/Integration/IntegrationTests.cs b/src/StrawberryShake/Client/test/Core.Tests/Integration/IntegrationTests.cs
index cdd8247b93d..899f9c10e31 100644
--- a/src/StrawberryShake/Client/test/Core.Tests/Integration/IntegrationTests.cs
+++ b/src/StrawberryShake/Client/test/Core.Tests/Integration/IntegrationTests.cs
@@ -3,7 +3,7 @@
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
-using ChilliCream.Testing;
+using CookieCrumble;
using StrawberryShake.Integration.Mappers;
using StrawberryShake.Serialization;
diff --git a/src/StrawberryShake/Client/test/Core.Tests/Integration/Mappers/DroidHeroMapper.cs b/src/StrawberryShake/Client/test/Core.Tests/Integration/Mappers/DroidHeroMapper.cs
index ab783ca33b7..4c326bb94f5 100644
--- a/src/StrawberryShake/Client/test/Core.Tests/Integration/Mappers/DroidHeroMapper.cs
+++ b/src/StrawberryShake/Client/test/Core.Tests/Integration/Mappers/DroidHeroMapper.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using ChilliCream.Testing;
namespace StrawberryShake.Integration.Mappers
{
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityGeneratorTests.cs
index ebe07373ebe..add4e822cc4 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/EntityGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ErrorGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ErrorGeneratorTests.cs
index 1af2a362e0d..ee2a16412e5 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ErrorGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ErrorGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs
index 9ce46417165..8582a33dd75 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs
@@ -2,15 +2,11 @@
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.CodeAnalysis;
-using ChilliCream.Testing;
using HotChocolate;
using HotChocolate.Language;
-using Snapshooter;
-using Snapshooter.Xunit;
using StrawberryShake.CodeGeneration.Analyzers;
using StrawberryShake.CodeGeneration.Analyzers.Models;
using StrawberryShake.CodeGeneration.Utilities;
-using Snapshot = Snapshooter.Xunit.Snapshot;
using RequestStrategyGen = StrawberryShake.Tools.Configuration.RequestStrategy;
using static StrawberryShake.CodeGeneration.CSharp.CSharpGenerator;
@@ -140,11 +136,7 @@ public static void AssertResult(
if (settings.SnapshotFile is not null)
{
- documents.ToString()
- .MatchSnapshot(
- new SnapshotFullName(
- settings.SnapshotFile,
- Snapshot.FullName().FolderPath));
+ MatchSnapshotAtPath(documents.ToString(), settings.SnapshotFile);
}
else
{
@@ -200,12 +192,17 @@ public static AssertSettings CreateIntegrationTest(
TransportProfile[]? profiles = null,
AccessModifier accessModifier = AccessModifier.Public,
bool noStore = false,
- [CallerMemberName] string? testName = null)
+ [CallerMemberName] string? testName = null,
+ [CallerFilePath] string? callerFilePath = null)
{
- var snapshotFullName = Snapshot.FullName();
- var testFile = System.IO.Path.Combine(
- snapshotFullName.FolderPath,
- testName + "Test.cs");
+ ArgumentException.ThrowIfNullOrEmpty(testName);
+ ArgumentException.ThrowIfNullOrEmpty(callerFilePath);
+
+ var folder = System.IO.Path.GetDirectoryName(callerFilePath)
+ ?? throw new ArgumentException(
+ $"Could not determine directory from caller file path '{callerFilePath}'.",
+ nameof(callerFilePath));
+ var testFile = System.IO.Path.Combine(folder, testName + "Test.cs");
var ns = "StrawberryShake.CodeGeneration.CSharp.Integration." + testName;
if (!File.Exists(testFile))
@@ -219,13 +216,11 @@ public static AssertSettings CreateIntegrationTest(
return new AssertSettings
{
- ClientName = testName! + "Client",
+ ClientName = testName + "Client",
Namespace = ns,
AccessModifier = accessModifier,
StrictValidation = true,
- SnapshotFile = System.IO.Path.Combine(
- snapshotFullName.FolderPath,
- testName + "Test.Client.cs"),
+ SnapshotFile = System.IO.Path.Combine(folder, testName + "Test.Client.cs"),
RequestStrategy = requestStrategy,
NoStore = noStore,
Profiles = (profiles ??
@@ -235,6 +230,46 @@ public static AssertSettings CreateIntegrationTest(
};
}
+ private static void MatchSnapshotAtPath(string content, string snapshotFile)
+ {
+ content = content.Replace("\r\n", "\n");
+
+ if (!File.Exists(snapshotFile))
+ {
+ CheckStrictMode();
+ File.WriteAllText(snapshotFile, content);
+ return;
+ }
+
+ var existing = File.ReadAllText(snapshotFile).Replace("\r\n", "\n");
+ if (string.Equals(existing, content, StringComparison.Ordinal))
+ {
+ return;
+ }
+
+ var folder = System.IO.Path.GetDirectoryName(snapshotFile)!;
+ var mismatchDir = System.IO.Path.Combine(folder, "__snapshots__", "__mismatch__");
+ Directory.CreateDirectory(mismatchDir);
+ var mismatchFile = System.IO.Path.Combine(mismatchDir, System.IO.Path.GetFileName(snapshotFile));
+ File.WriteAllText(mismatchFile, content);
+
+ Assert.Fail($"Snapshot mismatch. Mismatch file written to {mismatchFile}");
+ }
+
+ private static void CheckStrictMode()
+ {
+ var value = Environment.GetEnvironmentVariable("COOKIE_CRUMBLE_STRICT_MODE");
+
+ if (string.Equals(value, "on", StringComparison.Ordinal)
+ || (bool.TryParse(value, out var b) && b))
+ {
+ Assert.Fail(
+ "Strict mode is enabled and no snapshot has been found "
+ + "for the current test. Create a new snapshot locally and "
+ + "rerun your tests.");
+ }
+ }
+
private static ClientModel CreateClientModel(
string[] sourceText,
bool strictValidation,
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/InputGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/InputGeneratorTests.cs
index 8da411722c0..3fee3ce1d60 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/InputGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/InputGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/AnyScalarDefaultSerializationTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/AnyScalarDefaultSerializationTest.cs
index 69feefb6510..f81b11d920e 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/AnyScalarDefaultSerializationTest.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/AnyScalarDefaultSerializationTest.cs
@@ -2,7 +2,6 @@
using HotChocolate.AspNetCore.Tests.Utilities;
using HotChocolate.Types;
using Microsoft.Extensions.DependencyInjection;
-using Snapshooter.Xunit;
using StrawberryShake.Transport.WebSockets;
namespace StrawberryShake.CodeGeneration.CSharp.Integration.AnyScalarDefaultSerialization;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.cs
index e67578c7768..2c9de883612 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/EntityIdOrDataTest.cs
@@ -1,7 +1,6 @@
using HotChocolate.AspNetCore.Tests.Utilities;
using Microsoft.Extensions.DependencyInjection;
using HotChocolate.Types;
-using Snapshooter.Xunit;
namespace StrawberryShake.CodeGeneration.CSharp.Integration.EntityIdOrData;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.cs
index 60674bf7cda..8a70f4de852 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.cs
@@ -1,6 +1,5 @@
using HotChocolate.AspNetCore.Tests.Utilities;
using Microsoft.Extensions.DependencyInjection;
-using Snapshooter.Xunit;
using StrawberryShake.Transport.WebSockets;
namespace StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsIntrospection;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.cs
index 2b421d1d4b8..59c2b4f5bd5 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnInterfacesTest.cs
@@ -1,6 +1,5 @@
using HotChocolate.AspNetCore.Tests.Utilities;
using Microsoft.Extensions.DependencyInjection;
-using Snapshooter.Xunit;
using StrawberryShake.Transport.WebSockets;
namespace StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnInterfaces;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.cs
index ecfc8a1dcfc..2a0db3b6aa3 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsTypeNameOnUnionsTest.cs
@@ -1,6 +1,5 @@
using HotChocolate.AspNetCore.Tests.Utilities;
using Microsoft.Extensions.DependencyInjection;
-using Snapshooter.Xunit;
using StrawberryShake.Transport.WebSockets;
namespace StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsTypeNameOnUnions;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.cs
index 22fb7d9a449..c0ed1a1945d 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsUnionListTest.cs
@@ -1,6 +1,5 @@
using HotChocolate.AspNetCore.Tests.Utilities;
using Microsoft.Extensions.DependencyInjection;
-using Snapshooter.Xunit;
using StrawberryShake.Transport.WebSockets;
namespace StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsUnionList;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs
index ed4f613148a..62544fe22cc 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using StrawberryShake.Tools.Configuration;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap
index 5a902cdb1d5..b2d41708e6f 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/__snapshots__/StarWarsIntrospectionTest.Execute_StarWarsIntrospection_Test.snap
@@ -1,4 +1,4 @@
-{
+{
"Data": {
"__schema": {
"QueryType": {
@@ -7471,4 +7471,4 @@
"Errors": [],
"Extensions": {},
"ContextData": {}
-}
\ No newline at end of file
+}
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/NoStoreStarWarsGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/NoStoreStarWarsGeneratorTests.cs
index 2fab6dad93a..f90446b29d4 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/NoStoreStarWarsGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/NoStoreStarWarsGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/OperationGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/OperationGeneratorTests.cs
index dd7c5d999b0..be29459cd53 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/OperationGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/OperationGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ScalarGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ScalarGeneratorTests.cs
index 31c4e3d41e0..47db0dde6a5 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ScalarGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/ScalarGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using Xunit.Sdk;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/SchemaGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/SchemaGeneratorTests.cs
index 572f56f7e67..b5d0892970f 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/SchemaGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/SchemaGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StarWarsGeneratorTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StarWarsGeneratorTests.cs
index 5b682d0405c..c748a88d15e 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StarWarsGeneratorTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StarWarsGeneratorTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs
index 6adc40bdaa1..681b6e5b10b 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs
@@ -1,15 +1,11 @@
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.CodeAnalysis;
-using ChilliCream.Testing;
using HotChocolate;
using HotChocolate.Language;
-using Snapshooter;
-using Snapshooter.Xunit;
using StrawberryShake.CodeGeneration.Analyzers;
using StrawberryShake.CodeGeneration.Analyzers.Models;
using StrawberryShake.CodeGeneration.Utilities;
-using Snapshot = Snapshooter.Xunit.Snapshot;
using RequestStrategyGen = StrawberryShake.Tools.Configuration.RequestStrategy;
using static StrawberryShake.CodeGeneration.CSharp.CSharpGenerator;
@@ -138,11 +134,7 @@ public static void AssertResult(
if (settings.SnapshotFile is not null)
{
- documents.ToString()
- .MatchSnapshot(
- new SnapshotFullName(
- settings.SnapshotFile,
- Snapshot.FullName().FolderPath));
+ MatchSnapshotAtPath(documents.ToString(), settings.SnapshotFile);
}
else
{
@@ -197,12 +189,17 @@ public static AssertSettings CreateIntegrationTest(
RequestStrategyGen requestStrategy = RequestStrategyGen.Default,
TransportProfile[]? profiles = null,
bool noStore = false,
- [CallerMemberName] string? testName = null)
+ [CallerMemberName] string? testName = null,
+ [CallerFilePath] string? callerFilePath = null)
{
- var snapshotFullName = Snapshot.FullName();
- var testFile = System.IO.Path.Combine(
- snapshotFullName.FolderPath,
- testName + "Test.cs");
+ ArgumentException.ThrowIfNullOrEmpty(testName);
+ ArgumentException.ThrowIfNullOrEmpty(callerFilePath);
+
+ var folder = System.IO.Path.GetDirectoryName(callerFilePath)
+ ?? throw new ArgumentException(
+ $"Could not determine directory from caller file path '{callerFilePath}'.",
+ nameof(callerFilePath));
+ var testFile = System.IO.Path.Combine(folder, testName + "Test.cs");
var ns = "StrawberryShake.CodeGeneration.CSharp.Integration." + testName;
if (!File.Exists(testFile))
@@ -216,12 +213,10 @@ public static AssertSettings CreateIntegrationTest(
return new AssertSettings
{
- ClientName = testName! + "Client",
+ ClientName = testName + "Client",
Namespace = ns,
StrictValidation = true,
- SnapshotFile = System.IO.Path.Combine(
- snapshotFullName.FolderPath,
- testName + "Test.Client.cs"),
+ SnapshotFile = System.IO.Path.Combine(folder, testName + "Test.Client.cs"),
RequestStrategy = requestStrategy,
NoStore = noStore,
Profiles = (profiles ??
@@ -231,6 +226,46 @@ public static AssertSettings CreateIntegrationTest(
};
}
+ private static void MatchSnapshotAtPath(string content, string snapshotFile)
+ {
+ content = content.Replace("\r\n", "\n");
+
+ if (!File.Exists(snapshotFile))
+ {
+ CheckStrictMode();
+ File.WriteAllText(snapshotFile, content);
+ return;
+ }
+
+ var existing = File.ReadAllText(snapshotFile).Replace("\r\n", "\n");
+ if (string.Equals(existing, content, StringComparison.Ordinal))
+ {
+ return;
+ }
+
+ var folder = System.IO.Path.GetDirectoryName(snapshotFile)!;
+ var mismatchDir = System.IO.Path.Combine(folder, "__snapshots__", "__mismatch__");
+ Directory.CreateDirectory(mismatchDir);
+ var mismatchFile = System.IO.Path.Combine(mismatchDir, System.IO.Path.GetFileName(snapshotFile));
+ File.WriteAllText(mismatchFile, content);
+
+ Assert.Fail($"Snapshot mismatch. Mismatch file written to {mismatchFile}");
+ }
+
+ private static void CheckStrictMode()
+ {
+ var value = Environment.GetEnvironmentVariable("COOKIE_CRUMBLE_STRICT_MODE");
+
+ if (string.Equals(value, "on", StringComparison.Ordinal)
+ || (bool.TryParse(value, out var b) && b))
+ {
+ Assert.Fail(
+ "Strict mode is enabled and no snapshot has been found "
+ + "for the current test. Create a new snapshot locally and "
+ + "rerun your tests.");
+ }
+ }
+
private static ClientModel CreateClientModel(
string[] sourceText,
bool strictValidation,
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Mappers/TestDataHelper.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Mappers/TestDataHelper.cs
index 35316ce7ee9..ca1db15b673 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Mappers/TestDataHelper.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Mappers/TestDataHelper.cs
@@ -6,7 +6,7 @@
using StrawberryShake.CodeGeneration.Analyzers;
using StrawberryShake.CodeGeneration.Analyzers.Models;
using StrawberryShake.CodeGeneration.Utilities;
-using static ChilliCream.Testing.FileResource;
+using static CookieCrumble.FileResource;
namespace StrawberryShake.CodeGeneration.Mappers;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/OperationDocumentHelperTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/OperationDocumentHelperTests.cs
index ee4b30438db..c1be9873d81 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/OperationDocumentHelperTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/OperationDocumentHelperTests.cs
@@ -1,6 +1,5 @@
using HotChocolate.Language;
-using Snapshooter.Xunit;
-using static ChilliCream.Testing.FileResource;
+using static CookieCrumble.FileResource;
using static HotChocolate.Language.Utf8GraphQLParser;
using static StrawberryShake.CodeGeneration.Utilities.OperationDocumentHelper;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/QueryDocumentRewriterTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/QueryDocumentRewriterTests.cs
index 40de5304962..486e695fcf3 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/QueryDocumentRewriterTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/QueryDocumentRewriterTests.cs
@@ -3,7 +3,6 @@
using HotChocolate.Language.Utilities;
using HotChocolate.StarWars;
using Microsoft.Extensions.DependencyInjection;
-using Snapshooter.Xunit;
namespace StrawberryShake.CodeGeneration.Utilities;
diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/SchemaHelperTests.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/SchemaHelperTests.cs
index 9453173af84..3ff109307c2 100644
--- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/SchemaHelperTests.cs
+++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/SchemaHelperTests.cs
@@ -1,4 +1,3 @@
-using ChilliCream.Testing;
using HotChocolate.Language;
using HotChocolate.Types;
using StrawberryShake.CodeGeneration.Extensions;
diff --git a/src/StrawberryShake/CodeGeneration/test/Directory.Build.props b/src/StrawberryShake/CodeGeneration/test/Directory.Build.props
index 895e450bc18..a88f34ecaa6 100644
--- a/src/StrawberryShake/CodeGeneration/test/Directory.Build.props
+++ b/src/StrawberryShake/CodeGeneration/test/Directory.Build.props
@@ -7,11 +7,17 @@
+
+
-
+
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -19,7 +25,6 @@
-
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -27,4 +32,11 @@
+
+
+
+
+