public void TestNonexistentFileRemoval() { string fileSource = Path.Combine(TestConstants.TestDirectory, "a"); RemoveCommand rmc = new RemoveCommand(fileSource); Assert.DoesNotThrow(() => rmc.Execute()); }
public void TestInvalidSourceFilePath() { string src = TestConstants.TestDirectory + "/\0.txt"; RemoveCommand rmc = new RemoveCommand(src); Assert.Throws <ArgumentException>(() => rmc.Execute()); }
public void TestNullSourceFilePath() { string src = null; RemoveCommand rmc = new RemoveCommand(src); Assert.Throws <ArgumentNullException>(() => rmc.Execute()); }
private string InterpredCommand(string[] data, string commandName) { Command addCmd = new AddCommand(data, repository, unitFactory); Command reportcmd = new ReportCommand(data, repository, unitFactory); Command removecmd = new RemoveCommand(data, repository, unitFactory); string result = string.Empty; if (commandName == "fight") { Environment.Exit(0); } switch (commandName) { case "add": return(addCmd.Execute()); case "report": return(reportcmd.Execute()); case "fight": Environment.Exit(0); break; case "retire": return(removecmd.Execute()); default: throw new InvalidOperationException("Invalid command!"); } return(result); }
private void OnRemove(object sender, RoutedEventArgs e) { if (RemoveCommand != null && RemoveCommandParametr != null) { RemoveCommand.Execute(RemoveCommandParametr); } }
public void WhenRemoveValueIsNullOrEmpty_ThenSetSame(string removeValue) { var sut = new RemoveCommand(removeValue).SetValue(Value); sut.Execute(); Assert.That(sut.Result, Is.EqualTo(Value)); }
public void WhenRemoveValuePresent_ThenSet() { var sut = new RemoveCommand("John").SetValue(Value); sut.Execute(); Assert.That(sut.Result, Is.EqualTo(" Smith Smith")); }
public void WhenRemoveValueNotPresent_ThenSetSame() { var sut = new RemoveCommand("Peter").SetValue(Value); sut.Execute(); Assert.That(sut.Result, Is.EqualTo(Value)); }
public void TestDirectoryWrongModeRemoval() { string dirSource = Path.Combine(TestConstants.TestDirectory, "a"); Directory.CreateDirectory(Path.Combine(dirSource, "b")); RemoveCommand rmc = new RemoveCommand(dirSource, RemoveCommand.Mode.Directory); Assert.Throws <IOException>(() => rmc.Execute()); }
public bool Remove(params string[] args) { if (args == null) { throw new ArgumentNullException("args"); } var command = new RemoveCommand(args); return(command.Execute()); }
public void RemoveCommandTest() { ICommand removeCommand = new RemoveCommand("REMOVE 3 E"); var result = removeCommand.Execute(root); var staff = treeVisitor.Find(root, x => x.Name == "3").Data; Assert.IsNull(staff.Permissions.FirstOrDefault(x => x.Name == "E")); }
public static void GenerateAndRunTestCases(string command, int itemIdToChange, string expectedResultMessage, string message) { GGList originalList = new GGList(); AddOriginalDataToList(originalList); GGList expectedList = new GGList(); CreateExpectedList(expectedList, itemIdToChange); RemoveCommand rmCommand = new RemoveCommand(); GGResult actualResult = rmCommand.Execute(command, originalList); Assert.AreEqual(expectedList, originalList, message); Assert.AreEqual(expectedResultMessage, actualResult.GetNotice(), "result message"); }
public void TestNonexistentDirectoryRemoval() { string dirSource = Path.Combine(TestConstants.TestDirectory, "a"); RemoveCommand rmc1 = new RemoveCommand(dirSource, RemoveCommand.Mode.Directory); RemoveCommand rmc2 = new RemoveCommand(dirSource, RemoveCommand.Mode.Recursive); Assert.DoesNotThrow(() => rmc1.Execute()); Assert.DoesNotThrow(() => rmc2.Execute()); }
public void ProjectRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _projectService.Object, _jobDefinitionService.Object) { Name = "Project 2" }; var resultMessage = command.Execute(); Assert.Equal("Project Project 2 was not found", resultMessage); }
public void ServiceRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y", "userPassword"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _externalServiceService.Object) { Name = "Default-VSTS" }; var resultMessage = command.Execute(); Assert.Equal("External Service Default-VSTS was not found", resultMessage); }
public void ProjectRemove_Execute_ReturnsSuccessMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _projectService.Object, _jobDefinitionService.Object) { Name = "Project 1" }; var resultMessage = command.Execute(); Assert.Equal("Project Project 1 has been removed successfully", resultMessage); }
public void TestSimple() { string src = Path.Combine(TestConstants.TestDirectory, "a.txt"); const string text = "12345"; File.WriteAllText(src, text); RemoveCommand rmc = new RemoveCommand(src); rmc.Execute(); Assert.IsFalse(File.Exists(src)); }
public void ServiceRemove_Execute_ReturnsSuccessMessage() { var console = new TestConsole(_output, "y", "userPassword"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _externalServiceService.Object) { Name = "Default-Github" }; var resultMessage = command.Execute(); Assert.Equal("External Service Default-Github has been removed successfully", resultMessage); }
public void EngineRemove_Execute_ReturnsSuccessMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _engineService.Object) { Name = "Engine01" }; var resultMessage = command.Execute(); Assert.Equal("Engine Engine01 has been removed successfully", resultMessage); }
public void TestDirectoryRecursiveRemoval() { string dirSource = Path.Combine(TestConstants.TestDirectory, "a/b"); Directory.CreateDirectory(dirSource); RemoveCommand rmc = new RemoveCommand(dirSource, RemoveCommand.Mode.Recursive); rmc.Execute(); Assert.IsFalse(Directory.Exists(dirSource)); }
public void EngineRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _engineService.Object) { Name = "Engine02" }; var resultMessage = command.Execute(); Assert.Equal("Engine Engine02 was not found", resultMessage); }
public void AccountRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _accountService.Object) { User = "******" }; var resultMessage = command.Execute(); Assert.Equal("User [email protected] was not found", resultMessage); }
public void ConfigRemove_Execute_ReturnsSuccess() { var console = new TestConsole(_output); var command = new RemoveCommand(_engineConfig.Object, console, (new Mock <ILogger <RemoveCommand> >()).Object) { ConfigName = "config1" }; var message = command.Execute(); Assert.True(!_configs.ContainsKey("config1")); Assert.Equal("Config \"config1\" has been removed.", message); }
public void ConfigRemove_RemoveAll_Execute_ReturnsSuccess() { var console = new TestConsole(_output); var command = new RemoveCommand(_engineConfig.Object, console, (new Mock <ILogger <RemoveCommand> >()).Object) { RemoveAll = true }; var message = command.Execute(); Assert.Empty(_configs); Assert.Equal("Config values have been removed successfully.", message); }
public void MemberRemove_Execute_ReturnsSuccessMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _projectMemberService.Object, _projectService.Object, _accountService.Object) { Project = "Project 1", User = "******" }; var resultMessage = command.Execute(); Assert.Equal("User [email protected] has been removed from project Project 1", resultMessage); }
public void TestFileRecursiveRemoval() { string fileSource = Path.Combine(TestConstants.TestDirectory, "a"); const string text = "12345"; File.WriteAllText(fileSource, text); RemoveCommand rmc = new RemoveCommand(fileSource, RemoveCommand.Mode.Recursive); rmc.Execute(); Assert.IsFalse(File.Exists(fileSource)); }
public void TestEmptyDirectoryRemoval() { string emptyDirSource = Path.Combine(TestConstants.TestDirectory, "a"); Directory.CreateDirectory(emptyDirSource); RemoveCommand rmc = new RemoveCommand(emptyDirSource, RemoveCommand.Mode.Directory); rmc.Execute(); Assert.IsFalse(Directory.Exists(emptyDirSource)); }
public void MemberRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _projectMemberService.Object, _projectService.Object, _accountService.Object) { Project = "Project 1", User = "******" }; var resultMessage = command.Execute(); Assert.Equal("Failed to remove user [email protected]. Make sure the project name and user email are correct.", resultMessage); }
public void ModelRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _projectService.Object, _projectModelService.Object) { Project = "Project 1", Name = "Tag" }; var resultMessage = command.Execute(); Assert.Equal("Failed to remove model Tag. Make sure the project and model names are correct.", resultMessage); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { Window window = Window.GetWindow(this); var test = (sender as Button).CommandParameter; RemoveCommand rm = new RemoveCommand(); object[] param = new object[3]; param[0] = DataContext; param[1] = _id; param[2] = window.DataContext; rm.Execute(param); }
public void JobRemove_Execute_ReturnsNotFoundMessage() { var console = new TestConsole(_output, "y"); var command = new RemoveCommand(console, LoggerMock.GetLogger <RemoveCommand>().Object, _projectService.Object, _jobDefinitionService.Object) { Project = "Project 2", Name = "Default" }; var resultMessage = command.Execute(); Assert.Equal("Failed to remove job definition Default. Make sure the project and job definition names are correct.", resultMessage); }