Skip to content

Commit

Permalink
No need for ContainerAttachedGremlinQuerySource. The container fixtur…
Browse files Browse the repository at this point in the history
…es will dispose of the source.
  • Loading branch information
danielcweber committed Aug 12, 2024
1 parent 9ba05e5 commit 351b2d1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 63 deletions.
62 changes: 1 addition & 61 deletions test/Tests.Fixtures/TestContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,6 @@ namespace ExRam.Gremlinq.Tests.Fixtures
{
public abstract class TestContainerFixtureBase : GremlinqFixture
{
private sealed class ContainerAttachedGremlinQuerySource : IGremlinQuerySource, IAsyncDisposable
{
private readonly IContainer _container;
private readonly IGremlinQuerySource _baseSource;

public ContainerAttachedGremlinQuerySource(IContainer container, IGremlinQuerySource baseSource)
{
_container = container;
_baseSource = baseSource;
}

IEdgeGremlinQuery<TEdge> IStartGremlinQuery.AddE<TEdge>(TEdge edge) => _baseSource.AddE(edge);

IEdgeGremlinQuery<TEdge> IStartGremlinQuery.AddE<TEdge>() => _baseSource.AddE<TEdge>();

IVertexGremlinQuery<TVertex> IStartGremlinQuery.AddV<TVertex>(TVertex vertex) => _baseSource.AddV(vertex);

IVertexGremlinQuery<TVertex> IStartGremlinQuery.AddV<TVertex>() => _baseSource.AddV<TVertex>();

IGremlinQueryAdmin IStartGremlinQuery.AsAdmin() => _baseSource.AsAdmin();

IGremlinQuerySource IGremlinQuerySource.ConfigureEnvironment(Func<IGremlinQueryEnvironment, IGremlinQueryEnvironment> environmentTransformation) => _baseSource.ConfigureEnvironment(environmentTransformation);

IEdgeGremlinQuery<object> IStartGremlinQuery.E(object id) => _baseSource.E(id);

IEdgeGremlinQuery<object> IStartGremlinQuery.E(params object[] ids) => _baseSource.E(ids);

IEdgeGremlinQuery<TEdge> IStartGremlinQuery.E<TEdge>(object id) => _baseSource.E<TEdge>(id);

IEdgeGremlinQuery<TEdge> IStartGremlinQuery.E<TEdge>(params object[] ids) => _baseSource.E<TEdge>(ids);

IGremlinQuery<TElement> IStartGremlinQuery.Inject<TElement>(params TElement[] elements) => _baseSource.Inject(elements);

IEdgeGremlinQuery<TNewEdge> IStartGremlinQuery.ReplaceE<TNewEdge>(TNewEdge edge) => _baseSource.ReplaceE(edge);

IVertexGremlinQuery<TNewVertex> IStartGremlinQuery.ReplaceV<TNewVertex>(TNewVertex vertex) => _baseSource.ReplaceV(vertex);

IVertexGremlinQuery<object> IStartGremlinQuery.V(object id) => _baseSource.V(id);

IVertexGremlinQuery<object> IStartGremlinQuery.V(params object[] ids) => _baseSource.V(ids);

IVertexGremlinQuery<TVertex> IStartGremlinQuery.V<TVertex>(object id) => _baseSource.V<TVertex>(id);

IVertexGremlinQuery<TVertex> IStartGremlinQuery.V<TVertex>(params object[] ids) => _baseSource.V<TVertex>(ids);

IGremlinQuerySource IGremlinQuerySource.WithSideEffect<TSideEffect>(StepLabel<TSideEffect> label, TSideEffect value) => _baseSource.WithSideEffect(label, value);

TQuery IGremlinQuerySource.WithSideEffect<TSideEffect, TQuery>(TSideEffect value, Func<IGremlinQuerySource, StepLabel<TSideEffect>, TQuery> continuation) => _baseSource.WithSideEffect(value, continuation);

IGremlinQuerySource IGremlinQuerySource.ConfigureMetadata(Func<IImmutableDictionary<object, object?>, IImmutableDictionary<object, object?>> metadataTransformation) => _baseSource.ConfigureMetadata(metadataTransformation);

async ValueTask IAsyncDisposable.DisposeAsync()
{
await using(_container)
{
await _container.StopAsync();
}
}
}

private readonly int _port;

private IContainer? _container;
Expand All @@ -85,7 +25,7 @@ protected TestContainerFixtureBase(int port = 8182)
protected sealed override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g)
{
if (_container is { } container)
return TransformQuerySource(_container, new ContainerAttachedGremlinQuerySource(container, g));
return TransformQuerySource(container, g);

throw new InvalidOperationException();
}
Expand Down
2 changes: 0 additions & 2 deletions test/Tests.Infrastructure/GremlinqFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public virtual async Task InitializeAsync()

public virtual async Task DisposeAsync()
{
if (_g is IAsyncDisposable disposable)
await disposable.DisposeAsync();
}

public IGremlinQuerySource G => _g ?? throw new InvalidOperationException();
Expand Down

0 comments on commit 351b2d1

Please sign in to comment.