public void AddLinkTwice() { var dict = BuildTestTree(); AddLinkCommand command = new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"], true); command.Execute(); }
public void Execute_WithOnlyRequiredArgumentsRunTwice_ShouldShowDuplicatePathErrorMessage() { // Arrange const string testPath = @"c:/config.linker"; const string testSourcePath = @"c:/demo/"; const string testTargetPath = "testTargetDirectory"; AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, ConfigLink.LinkType.Default, testPath); testConfigHandler.Setup(m => m.LoadConfig(testPath)).Returns(testConfig.Object); // Act testConsole.ShouldRecordHistory = false; command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); testConsole.ShouldRecordHistory = true; command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); // Assert Assert.IsTrue(testConsole.GetHistory().Contains("already exists", StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(testConsole.GetHistory().Contains(testTargetPath, StringComparison.OrdinalIgnoreCase)); }
public void AddLinkAndUndo() { var dict = BuildTestTree(); AddLinkCommand command = new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"]); Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"])); Assert.AreEqual(1, dict["Node 2.2"].CountParentNodes()); command.Execute(); Assert.AreEqual("Problem,Node 1,Node 1.1,Node 2.2,Node 1.2,Node 2,Node 2.1,Node 2.1.1,Node 2.2", StringifyTree(dict["Problem"])); Assert.AreEqual(2, dict["Node 2.2"].CountParentNodes()); Assert.AreEqual(true, command.Executed); command.Undo(); Assert.AreEqual(1, dict["Node 2.2"].CountParentNodes()); Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"])); Assert.AreEqual(false, command.Executed); }
public void Execute_WithInvalidSourceFolder_ShouldShowInvalidPathErrorMessage() { // Arrange const string testPath = @"c:/config.linker"; const string testSourcePath = @"c:/some path that does not exist"; const string testTargetPath = "testTargetDirectory"; AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, ConfigLink.LinkType.Default, testPath); testConfigHandler.Setup(m => m.LoadConfig(testPath)).Returns(testConfig.Object); // Act command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); // Assert Assert.IsTrue(testConsole.GetHistory().Contains("does not exist", StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(testConsole.GetHistory().Contains(testSourcePath, StringComparison.OrdinalIgnoreCase)); }
public void Execute_WithLinkFlagJunction_ShouldCreateJunctionLink() { // Arrange const string testPath = @"c:/config.linker"; const string testSourcePath = @"c:/demo/"; const string testTargetPath = @"c:/folder/anotherfolder/yetanotherfolder"; const ConfigLink.LinkType testLinkType = ConfigLink.LinkType.Junction; AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, testLinkType, testPath); testConfigHandler.Setup(m => m.LoadConfig(testPath)).Returns(testConfig.Object); // Act command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); // Assert Assert.IsTrue(testConfigHandler.Object.LoadConfig(testPath).LinkList.Any(link => link.sourcePath.Equals(testSourcePath) && link.targetPath.Equals(testTargetPath) && link.linkType == testLinkType)); }
public void Execute_WithOnlyRequiredArguments_WillCreateDefaultDirectoryLink() { // Arrange const string testPath = @"c:/config.linker"; const string testSourcePath = @"c:/demo/"; const string testTargetPath = "testTargetDirectory"; AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, ConfigLink.LinkType.Default, testPath); testLinks.Add(testLinkElements[0]); testLinks.Add(testLinkElements[1]); testConfigHandler.Setup(m => m.LoadConfig(testPath)).Returns(testConfig.Object); // Act command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); // Assert Assert.IsTrue(testConfigHandler.Object.LoadConfig(testPath).LinkList.Any(link => link.sourcePath.Equals(testSourcePath) && link.targetPath.Equals(testTargetPath) && link.linkType == ConfigLink.LinkType.Default)); }