Skip to content

Commit

Permalink
Merge pull request #172 from Lombiq/issue/OSOE-464-remove-sync-over-a…
Browse files Browse the repository at this point in the history
…sync

OSOE-464: Removing sync over async in tests
  • Loading branch information
dministro authored Dec 13, 2022
2 parents 6580057 + e4ff56c commit 61af6a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public ManualConnectingIndexServiceFixture()
.Range(0, 10)
.Select(n => new TestDocument { Name = NamePrefix + n.ToTechnicalString() })
.ToArray();

if (File.Exists(FileName)) File.Delete(FileName);
CreateDatabaseAsync().Wait();
}

public async Task SessionAsync(Func<ISession, Task> action)
Expand All @@ -59,6 +56,8 @@ public async Task SessionAsync(Func<ISession, Task> action)

private async Task CreateDatabaseAsync()
{
if (File.Exists(FileName)) File.Delete(FileName);

Store = (Store)await StoreFactory.CreateAndInitializeAsync(_configuration);
var dbAccessorMock = new Mock<IDbConnectionAccessor>();
dbAccessorMock.Setup(x => x.CreateConnection())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public Task AllIndexShouldRetrieveItsDocument() => _fixture.SessionAsync(async s
var query = session.Query<TestDocument, TestDocumentIndex>(index => index.Number.IsIn(numbers));
var list = await query.ListAsync();
var documents = list.ToList();
documents.Select(x => x.Name)
.ShouldBe(_fixture.Documents.Where((_, index) => index is not 3 and not 6).Select(x => x.Name));
documents.Select(document => document.Name)
.ShouldBe(_fixture.Documents.Where((_, index) => index is not 3 and not 6).Select(document => document.Name));
});

[Fact]
public Task MissingOrDeletedIndexShouldNotRetrieveAnyDocument() => _fixture.SessionAsync(async session =>
{
var numbers = new[] { 3, 6 };
var documents = (await session.Query<TestDocument, TestDocumentIndex>(x => x.Number.IsIn(numbers)).ListAsync()).ToList();
var documents = (await session.Query<TestDocument, TestDocumentIndex>(index => index.Number.IsIn(numbers)).ListAsync()).ToList();
documents.ShouldBeEmpty();
});
}

0 comments on commit 61af6a0

Please sign in to comment.