forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCdCommandTests.cs
More file actions
49 lines (41 loc) · 1.22 KB
/
CdCommandTests.cs
File metadata and controls
49 lines (41 loc) · 1.22 KB
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
using System;
using System.IO;
using Moq;
using ScriptCs.Contracts;
using ScriptCs.ReplCommands;
using Xunit;
namespace ScriptCs.Tests.ReplCommands
{
public class CdCommandTests
{
public class CommandNameProperty
{
[Fact]
public void ReturnsCd()
{
// act
var cmd = new CdCommand();
// assert
Assert.Equal("cd", cmd.CommandName);
}
}
public class ExecuteMethod
{
[Fact]
public void ChangesRelativePathBasedOnArg()
{
// arrange
var fs = new Mock<IFileSystem>();
var repl = new Mock<IRepl>();
var tempPath = Path.GetTempPath().TrimEnd(Path.DirectorySeparatorChar);
fs.Setup(x => x.CurrentDirectory).Returns(Path.Combine(tempPath, "dir"));
repl.Setup(x => x.FileSystem).Returns(fs.Object);
var cmd = new CdCommand();
// act
cmd.Execute(repl.Object, new[] { ".." });
// assert
fs.VerifySet(x => x.CurrentDirectory = tempPath, Times.Once());
}
}
}
}