Issue #21: implement worker bootstrap and options
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MxGateway.Worker.Bootstrap;
|
||||
|
||||
namespace MxGateway.Worker.Tests.Bootstrap;
|
||||
|
||||
internal sealed class MemoryWorkerEnvironment : IWorkerEnvironment
|
||||
{
|
||||
private readonly Dictionary<string, string> _values = new();
|
||||
private readonly Exception? _exception;
|
||||
|
||||
public MemoryWorkerEnvironment()
|
||||
{
|
||||
}
|
||||
|
||||
public MemoryWorkerEnvironment(Exception exception)
|
||||
{
|
||||
_exception = exception;
|
||||
}
|
||||
|
||||
public void Set(string name, string value)
|
||||
{
|
||||
_values[name] = value;
|
||||
}
|
||||
|
||||
public string? GetEnvironmentVariable(string name)
|
||||
{
|
||||
if (_exception is not null)
|
||||
{
|
||||
throw _exception;
|
||||
}
|
||||
|
||||
return _values.TryGetValue(name, out string value)
|
||||
? value
|
||||
: null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user