Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Remove AsDisposable and fix unit test problem in Xavier time (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Jun 11, 2019
1 parent 4f9131a commit b4c5e14
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 43 deletions.
34 changes: 0 additions & 34 deletions src/NuGet.Services.AzureSearch/AsDisposable.cs

This file was deleted.

3 changes: 1 addition & 2 deletions src/NuGet.Services.AzureSearch/DatabaseOwnerFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ public DatabaseOwnerFetcher(

public async Task<string[]> GetOwnersOrEmptyAsync(string id)
{
using (var entitiesContext = AsDisposable.Create(await _entitiesContextFactory.CreateAsync(readOnly: true)))
using (var entitiesContext = await _entitiesContextFactory.CreateAsync(readOnly: true))
{
_logger.LogInformation("Fetching owners for package registration with ID {PackageId}.", id);
var owners = await entitiesContext
.Value
.PackageRegistrations
.Where(pr => pr.Id == id)
.Select(pr => pr.Owners.Select(u => u.Username).ToList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ private async Task<IReadOnlyList<Package>> GetPackagesAsync(PackageRegistrationR
{
var minKey = range.MinKey;
var query = context
.Value
.Set<Package>()
.Include(x => x.PackageRegistration)
.Where(p => p.PackageStatusKey == PackageStatus.Available)
Expand Down Expand Up @@ -148,7 +147,6 @@ private async Task<IReadOnlyList<PackageRegistrationInfo>> GetPackageRegistratio
{
var minKey = range.MinKey;
var query = context
.Value
.Set<PackageRegistration>()
.Include(x => x.Owners)
.Where(pr => pr.Key >= minKey);
Expand Down Expand Up @@ -183,7 +181,6 @@ private async Task<IReadOnlyList<PackageRegistrationRange>> GetPackageRegistrati
// Get the number of packages per package registration key, in ascending order.
var stopwatch = Stopwatch.StartNew();
var packageCounts = await context
.Value
.Set<PackageRegistration>()
.OrderBy(pr => pr.Key)
.Select(pr => new
Expand Down Expand Up @@ -241,9 +238,9 @@ private async Task<IReadOnlyList<PackageRegistrationRange>> GetPackageRegistrati
}
}

private async Task<AsDisposable<IEntitiesContext>> CreateContextAsync()
private async Task<IEntitiesContext> CreateContextAsync()
{
return AsDisposable.Create(await _contextFactory.CreateAsync(readOnly: true));
return await _contextFactory.CreateAsync(readOnly: true);
}

private class PackageRegistrationRange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<Compile Include="Analysis\PackageIdCustomAnalyzer.cs" />
<Compile Include="Analysis\PackageIdCustomTokenizer.cs" />
<Compile Include="DatabaseOwnerFetcher.cs" />
<Compile Include="AsDisposable.cs" />
<Compile Include="IDatabaseOwnerFetcher.cs" />
<Compile Include="Owners2AzureSearch\IOwnerIndexActionBuilder.cs" />
<Compile Include="Owners2AzureSearch\IOwnerSetComparer.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task UsesMaxForCursorWithNoDependencies()
_collector.Verify(
x => x.RunAsync(
It.IsAny<ReadWriteCursor>(),
It.Is<ReadCursor>(c => c.Value == DateTime.MaxValue),
It.Is<ReadCursor>(c => c.Value == DateTime.MaxValue.ToUniversalTime()),
It.IsAny<CancellationToken>()),
Times.Once);
}
Expand Down

0 comments on commit b4c5e14

Please sign in to comment.