feat: initial commit

This commit is contained in:
Thom Lamb
2026-06-23 11:18:54 -05:00
parent fc3ce9a074
commit 1bb980f070
790 changed files with 149255 additions and 218 deletions
@@ -0,0 +1,68 @@
using System;
using Hangfire;
using Hangfire.Common;
using Hangfire.Server;
using Hangfire.Storage;
using Moq;
// https://github.com/HangfireIO/Hangfire/blob/master/tests/Hangfire.Core.Tests/Mocks/PerformContextMock.cs
namespace Strata.Analytics.Test.Unit.Biz.TestData
{
public class PerformContextMock
{
private readonly Lazy<PerformContext> _context;
public PerformContextMock()
{
Storage = new Mock<JobStorage>();
Connection = new Mock<IStorageConnection>();
BackgroundJob = new BackgroundJobMock();
CancellationToken = new Mock<IJobCancellationToken>();
_context = new Lazy<PerformContext>(
() => new PerformContext(Storage.Object, Connection.Object, BackgroundJob.Object, CancellationToken.Object));
}
public Mock<JobStorage> Storage { get; set; }
public Mock<IStorageConnection> Connection { get; set; }
public BackgroundJobMock BackgroundJob { get; set; }
public Mock<IJobCancellationToken> CancellationToken { get; set; }
public PerformContext Object => _context.Value;
public PerformingContext GetPerformingContext()
{
return new PerformingContext(Object);
}
public PerformedContext GetPerformedContext(object result = null, bool canceled = false, Exception exception = null)
{
return new PerformedContext(Object, result, canceled, exception);
}
}
public class BackgroundJobMock
{
private readonly Lazy<BackgroundJob> _object;
public BackgroundJobMock()
{
Id = "JobId";
Job = Job.FromExpression(() => SomeMethod());
CreatedAt = DateTime.UtcNow;
_object = new Lazy<BackgroundJob>(
() => new BackgroundJob(Id, Job, CreatedAt));
}
public string Id { get; set; }
public Job Job { get; set; }
public DateTime CreatedAt { get; set; }
public BackgroundJob Object => _object.Value;
public static void SomeMethod() { }
}
}