38 lines
804 B
C#
38 lines
804 B
C#
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;
|
|
}
|
|
}
|