-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerEnvironmentTests.cs
50 lines (41 loc) · 1.61 KB
/
DockerEnvironmentTests.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace CSharpInteractive.Tests;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")]
public class DockerEnvironmentTests
{
private readonly Mock<IEnvironment> _environment = new();
private readonly Mock<IFileExplorer> _fileExplorer = new();
[Theory]
[InlineData("Windows", "docker.exe")]
[InlineData("Linux", "docker")]
[InlineData("FreeBSD", "docker")]
[InlineData("Unknown", "docker")]
public void ShouldFindPath(string platform, string defaultPath)
{
// Given
_environment.SetupGet(i => i.OperatingSystemPlatform).Returns(OSPlatform.Create(platform));
_fileExplorer.Setup(i => i.FindFiles(defaultPath, "DOCKER_HOME")).Returns(["Abc", "Xyz"]);
// When
var instance = CreateInstance();
// Then
instance.Path.ShouldBe("Abc");
}
[Theory]
[InlineData("Windows", "docker.exe")]
[InlineData("Linux", "docker")]
[InlineData("FreeBSD", "docker")]
[InlineData("Unknown", "docker")]
public void ShouldProvideDefaultPathWhenException(string platform, string defaultPath)
{
// Given
_environment.SetupGet(i => i.OperatingSystemPlatform).Returns(OSPlatform.Create(platform));
_fileExplorer.Setup(i => i.FindFiles(defaultPath, "DOCKER_HOME")).Throws<Exception>();
// When
var instance = CreateInstance();
// Then
instance.Path.ShouldBe(defaultPath);
}
private DockerEnvironment CreateInstance() =>
new(_environment.Object, _fileExplorer.Object);
}