Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to mimick other test snapshots #1780

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/Providers.GremlinServer.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
{
[IntegrationTest("Linux", true)]
[IntegrationTest("Windows")]
public class IntegrationTests : QueryExecutionTest, IClassFixture<GremlinServerContainerFixture>
public class IntegrationTests : QueryExecutionTest, IClassFixture<GremlinServerContainerFixture>, ISourceFileNameProvider<IntegrationTests>
{
public IntegrationTests(GremlinServerContainerFixture fixture) : base(
fixture,
new ExecutingVerifier())
{
}

public static string ThisFilePath() => ThisFile.GetName();
public static string GetSourceFileName() => ThisFile.GetName();

[Fact]
public async Task FirstAsync() => (await _g
Expand Down
12 changes: 12 additions & 0 deletions test/Tests.Infrastructure/Extensions/SettingsTaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,17 @@ public static class SettingsTaskExtensions
public static SettingsTask ScrubRegex(this SettingsTask task, Regex regex, string replacement) => task.ScrubLinesWithReplace(str => regex.Replace(str, replacement));

public static SettingsTask ScrubGuids(this SettingsTask task) => task.ScrubRegex(GuidRegex, "12345678-9012-3456-7890-123456789012");

public static SettingsTask UseSnapshotDirectoryOf<T>(this SettingsTask task) where T : ISourceFileNameProvider<T>
{
if (Path.GetDirectoryName(T.GetSourceFileName()) is { } directory)
{
return task
.UseDirectory(directory)
.UseTypeName(typeof(T).Name);
}

throw new InvalidOperationException();
}
}
}
8 changes: 8 additions & 0 deletions test/Tests.Infrastructure/ISourceFileNameProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma warning disable CA2252
namespace ExRam.Gremlinq.Tests.Infrastructure
{
public interface ISourceFileNameProvider<T>
{
static abstract string GetSourceFileName();
}
}