Skip to content

Commit

Permalink
Update to Hangfire 1.8.4 (#358)
Browse files Browse the repository at this point in the history
* Update to Hangfire 1.8.4

* update to latest MongoDB and hangfire

removed moq
  • Loading branch information
gottscj authored Aug 14, 2023
1 parent 9768d25 commit 8d7b6f3
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 138 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

## Change log

### v1.9.8 (2023-08-14)
- Update to Hangfire.Core 1.8.5
- Update to MongoDB.Driver 2.21.0
- Replaced Moq with NSubstitue because Sponsorlink.
- https://www.reddit.com/r/dotnet/comments/15ljdcc/does_moq_in_its_latest_version_extract_and_send/

### v1.9.7 (2023-07-11)
- Update to Hangfire.Core 1.8.3
- Update to MongoDB.Driver 2.20.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description />
<Version>1.9.7</Version>
<Version>1.9.8</Version>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<Copyright>Copyright © 2014-2019 Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Copyright>
<Authors>Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Authors>
Expand All @@ -19,12 +19,12 @@
<ProjectReference Include="..\Hangfire.Mongo\Hangfire.Mongo.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="bootstrap" Version="5.3.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="bootstrap" Version="5.3.1" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="jquery" Version="3.7.0" />
<PackageReference Include="Mongo2Go" Version="3.1.3" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description />
<Version>1.9.7</Version>
<Version>1.9.8</Version>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<Copyright>Copyright © 2014-2019 Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Copyright>
<Authors>Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Authors>
Expand All @@ -19,11 +19,11 @@
<ProjectReference Include="..\Hangfire.Mongo\Hangfire.Mongo.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="bootstrap" Version="5.3.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="bootstrap" Version="5.3.1" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="jquery" Version="3.7.0" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyName>Hangfire.Mongo.Sample.NETCore</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Hangfire.Mongo.Sample.NETCore</PackageId>
<Version>1.9.7</Version>
<Version>1.9.8</Version>
<Description>MongoDB storage implementation for Hangfire (background job system for ASP.NET applications).</Description>
<Copyright>Copyright © 2014-2019 Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Copyright>
<Authors>Sergey Zwezdin, Martin Lobger, Jonas Gottschau</Authors>
Expand All @@ -18,8 +18,8 @@
<ProjectReference Include="..\Hangfire.Mongo\Hangfire.Mongo.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="Mongo2Go" Version="3.1.3" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Hangfire.Mongo.Tests/Hangfire.Mongo.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<ItemGroup>
<PackageReference Include="EphemeralMongo6" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/Hangfire.Mongo.Tests/Migration/Mongo/MigrationFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
using Hangfire.Mongo.Migration.Strategies.Backup;
using Hangfire.Mongo.Tests.Utils;
using MongoDB.Bson;
using MongoDB.Bson.IO;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
using Newtonsoft.Json;
using Xunit;

namespace Hangfire.Mongo.Tests.Migration.Mongo
Expand Down
21 changes: 9 additions & 12 deletions src/Hangfire.Mongo.Tests/Migration/Version15MigrationStepFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Hangfire.Mongo.Tests.Utils;
using MongoDB.Bson;
using MongoDB.Driver;
using Moq;
using Xunit;

namespace Hangfire.Mongo.Tests.Migration
Expand All @@ -16,14 +15,12 @@ namespace Hangfire.Mongo.Tests.Migration
public class Version15MigrationStepFacts
{
private readonly HangfireDbContext _dbContext;
private readonly Mock<IMongoMigrationContext> _mongoMigrationBagMock;
private readonly IMongoDatabase _database;

public Version15MigrationStepFacts(MongoDbFixture fixture)
{
_dbContext = fixture.CreateDbContext();
_database = _dbContext.Database;
_mongoMigrationBagMock = new Mock<IMongoMigrationContext>(MockBehavior.Strict);
}

[Fact]
Expand All @@ -47,7 +44,7 @@ public void ExecuteStep00_ValidExistingLockDto_Success()

// ACT
var result = new CreateUniqueLockIndex().Execute(_dbContext.Database, new MongoStorageOptions(),
_mongoMigrationBagMock.Object);
new MongoMigrationContext());

// ASSERT
var indexes = collection.Indexes.List().ToList();
Expand All @@ -72,7 +69,7 @@ public void ExecuteStep01_ValidExistingServerDto_Success()

// ACT
var result = new MakeServerDataEmbeddedDocument().Execute(_database, new MongoStorageOptions(),
_mongoMigrationBagMock.Object);
new MongoMigrationContext());

// ASSERT
var migratedServerDto = collection.Find(new BsonDocument()).Single();
Expand Down Expand Up @@ -101,7 +98,7 @@ public void ExecuteStep02_ValidExistingSetDto_Success()
collection.InsertOne(originalSetDto);

// ACT
var result = new CreateCompositeKeys().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new CreateCompositeKeys().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var migratedSetDto = collection.Find(new BsonDocument("_t", "SetDto")).Single();
Expand Down Expand Up @@ -142,7 +139,7 @@ public void ExecuteStep03_MultipleCountersNotDeleted_OldCountersDeleted()
collection.InsertMany(counters);

// ACT
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var remainingCounter = collection.Find(new BsonDocument("_t", "CounterDto")).Single();
Expand Down Expand Up @@ -192,7 +189,7 @@ public void ExecuteStep03_MultipleCountersDifferentValues_CountersMerged()
collection.InsertMany(counters);

// ACT
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var remainingCounter = collection.Find(new BsonDocument("_t", "CounterDto")).Single();
Expand All @@ -217,7 +214,7 @@ public void ExecuteStep03_OneCounter_Nothing()
});

// ACT
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var remainingCounter = collection.Find(new BsonDocument("_t", "CounterDto")).Single();
Expand Down Expand Up @@ -252,7 +249,7 @@ public void ExecuteStep03_TwoCountersSameValue_NewestChosen()
collection.InsertOne(expectedDoc);

// ACT
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new RemoveMergedCounters().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var remainingCounter = collection.Find(new BsonDocument("_t", "CounterDto")).Single();
Expand All @@ -278,7 +275,7 @@ public void ExecuteStep04_UpdateListDtoKeySchema_Success()
});

// ACT
var result = new UpdateListDtoKeySchema().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new UpdateListDtoKeySchema().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var listDto = collection.Find(new BsonDocument("_t", "ListDto")).Single();
Expand All @@ -298,7 +295,7 @@ public void ExecuteStep05_UpdateIndexes_Success()
collection.Indexes.DropAll();

// ACT
var result = new UpdateIndexes().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new UpdateIndexes().Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
Assert.True(result, "Expected migration to be successful, reported 'false'");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System.Linq;
using Hangfire.Mongo.Database;
using Hangfire.Mongo.Migration;
using Hangfire.Mongo.Migration.Steps.Version15;
using Hangfire.Mongo.Migration.Steps.Version16;
using Hangfire.Mongo.Tests.Utils;
using MongoDB.Bson;
using MongoDB.Driver;
using Moq;
using Xunit;

namespace Hangfire.Mongo.Tests.Migration
Expand All @@ -15,14 +12,12 @@ namespace Hangfire.Mongo.Tests.Migration
public class Version16MigrationStepFacts
{
private readonly HangfireDbContext _dbContext;
private readonly Mock<IMongoMigrationContext> _mongoMigrationBagMock;
private readonly IMongoDatabase _database;

public Version16MigrationStepFacts(MongoDbFixture fixture)
{
_dbContext = fixture.CreateDbContext();
_database = _dbContext.Database;
_mongoMigrationBagMock = new Mock<IMongoMigrationContext>(MockBehavior.Strict);
}

[Fact]
Expand All @@ -45,7 +40,7 @@ public void ExecuteStep00_SetDtoNotContainingValue_Success()

// ACT
var result = new UpdateSetDtoKeyAndValueField().Execute(_dbContext.Database, new MongoStorageOptions(),
_mongoMigrationBagMock.Object);
new MongoMigrationContext());

// ASSERT
var migratedSetDto = collection.Find(_ => true).Single();
Expand Down Expand Up @@ -73,7 +68,7 @@ public void ExecuteStep00_SetDtoNotCompositeKey_Success()

// ACT
var result = new UpdateSetDtoKeyAndValueField().Execute(_dbContext.Database, new MongoStorageOptions(),
_mongoMigrationBagMock.Object);
new MongoMigrationContext());

// ASSERT
var migratedSetDto = collection.Find(_ => true).Single();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Hangfire.Mongo.Migration;
using Hangfire.Mongo.Migration.Steps.Version17;
using Hangfire.Mongo.Migration.Steps.Version18;
using Hangfire.Mongo.Tests.Utils;
using MongoDB.Bson;
using MongoDB.Driver;
using Moq;
using Newtonsoft.Json.Linq;
using Xunit;

namespace Hangfire.Mongo.Tests.Migration
{
[Collection("Database")]
public class Version18MigrationStepFacts
{
private readonly Mock<IMongoMigrationContext> _mongoMigrationBagMock;
private readonly IMongoDatabase _database;

public Version18MigrationStepFacts(MongoDbFixture fixture)
{
var dbContext = fixture.CreateDbContext();
_database = dbContext.Database;
_mongoMigrationBagMock = new Mock<IMongoMigrationContext>(MockBehavior.Strict);
}

[Fact]
Expand All @@ -35,7 +29,8 @@ public void ExecuteStep01_UpdateIndexes_Success()
collection.Indexes.DropAll();

// ACT
var result = new UpdateIndexes().Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = new UpdateIndexes().Execute(_database,
new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
Assert.True(result, "Expected migration to be successful, reported 'false'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
using Hangfire.Mongo.Tests.Utils;
using MongoDB.Bson;
using MongoDB.Driver;
using Moq;
using Xunit;

namespace Hangfire.Mongo.Tests.Migration
{
[Collection("Database")]
public class Version19MigrationStepFacts
{
private readonly Mock<IMongoMigrationContext> _mongoMigrationBagMock;
private readonly IMongoDatabase _database;
private readonly Random _random;
private readonly AddTypeToSetDto _addTypeToSetDto;
public Version19MigrationStepFacts(MongoDbFixture fixture)
{
var dbContext = fixture.CreateDbContext();
_database = dbContext.Database;
_mongoMigrationBagMock = new Mock<IMongoMigrationContext>(MockBehavior.Strict);
_random = new Random();
_addTypeToSetDto = new AddTypeToSetDto();
}
Expand All @@ -41,7 +38,7 @@ public void ExecuteStep01_AddTypeToSetDto_Success()
CreateSetDto(),
});
// ACT
var result = _addTypeToSetDto.Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = _addTypeToSetDto.Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
Assert.True(result, "Expected migration to be successful, reported 'false'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@
using Hangfire.Mongo.Tests.Utils;
using MongoDB.Bson;
using MongoDB.Driver;
using Moq;
using Xunit;

namespace Hangfire.Mongo.Tests.Migration
{
[Collection("Database")]
public class Version20MigrationStepFacts
{
private readonly Mock<IMongoMigrationContext> _mongoMigrationBagMock;
private readonly IMongoDatabase _database;
private readonly Random _random;
private readonly IMongoMigrationStep _migration;
public Version20MigrationStepFacts(MongoDbFixture fixture)
{
var dbContext = fixture.CreateDbContext();
_database = dbContext.Database;
_mongoMigrationBagMock = new Mock<IMongoMigrationContext>(MockBehavior.Strict);
_random = new Random();
_migration = new RemoveJobQueueDto();
}
Expand All @@ -37,7 +34,7 @@ public void ExecuteStep01_MergeJobQueueIntoJobDto_Success()
collection.InsertMany(CreateJobQueueDtos());

// ACT
var result = _migration.Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = _migration.Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
Assert.True(result, "Expected migration to be successful, reported 'false'");
Expand All @@ -62,7 +59,7 @@ public void ExecuteStep01_AlreadyRunJobsGetsFetchedAtSet_Success()
collection.InsertMany(jobs);

// ACT
var result = _migration.Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = _migration.Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
Assert.True(result, "Expected migration to be successful, reported 'false'");
Expand Down Expand Up @@ -92,7 +89,7 @@ public void ExecuteStep02_AddIndexes_Success()
collection.InsertMany(CreateJobQueueDtos(0, 5));
var migration = new CompoundIndexes();
// ACT
var result = migration.Execute(_database, new MongoStorageOptions(), _mongoMigrationBagMock.Object);
var result = migration.Execute(_database, new MongoStorageOptions(), new MongoMigrationContext());

// ASSERT
var index = collection.Indexes.List().ToList().FirstOrDefault(b => b["name"].AsString == "IX_SetType_T_Score");
Expand Down
Loading

0 comments on commit 8d7b6f3

Please sign in to comment.