-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadFileCodeSourceTests.cs
29 lines (24 loc) · 1.13 KB
/
LoadFileCodeSourceTests.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
namespace CSharpInteractive.Tests;
public class LoadFileCodeSourceTests
{
private readonly Mock<IFilePathResolver> _filePathResolver = new();
private readonly Mock<IScriptContext> _workingDirectoryContext = new();
private readonly Mock<IDisposable> _workingDirectoryToken = new();
[Fact]
public void ShouldProvideLoadCommand()
{
// Given
var fullPath = Path.Combine("wd", "zx", "Abc");
_filePathResolver.Setup(i => i.TryResolve(Path.Combine("zx", "Abc"), out fullPath)).Returns(true);
var source = CreateInstance(Path.Combine("zx", "Abc"));
_workingDirectoryContext.Setup(i => i.CreateScope(source)).Returns(_workingDirectoryToken.Object);
// When
var expectedResult = source.ToArray();
// Then
expectedResult.ShouldBe([$"#load \"{Path.Combine("wd", "zx", "Abc")}\""]);
_workingDirectoryContext.Verify(i => i.CreateScope(source));
_workingDirectoryToken.Verify(i => i.Dispose());
}
private LoadFileCodeSource CreateInstance(string fileName) =>
new(_filePathResolver.Object, _workingDirectoryContext.Object, fileName);
}