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

OSOE-464: Removing sync over async in tests #172

Merged
merged 2 commits into from
Dec 13, 2022
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
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();
});
}