-
Notifications
You must be signed in to change notification settings - Fork 731
/
TestEnvironment.cs
25 lines (19 loc) · 795 Bytes
/
TestEnvironment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Collections.Immutable;
using Bicep.Core.Utils;
namespace Bicep.Core.UnitTests.Utils;
public class TestEnvironment : IEnvironment
{
private readonly ImmutableDictionary<string, string?> variables;
public TestEnvironment(ImmutableDictionary<string, string?> variables)
{
this.variables = variables;
}
public static IEnvironment Create(params (string key, string? value)[] variables)
=> new TestEnvironment(variables.ToImmutableDictionary(x => x.key, x => x.value));
public string? GetVariable(string variable)
=> variables.TryGetValue(variable, out var value) ? value : null;
public IEnumerable<string> GetVariableNames()
=> variables.Keys;
}