public void AssignmentTest() { ICommand command = new ListFilesCommand(); Assert.AreEqual("ListFiles", command.FullName); Assert.AreEqual("ls", command.ShortName); }
public void ListFilesCommand_Verify_1() { Mock <IIrbisConnection> mock = GetConnectionMock(); IIrbisConnection connection = mock.Object; ListFilesCommand command = new ListFilesCommand(connection); Assert.IsTrue(command.Verify(false)); }
public void ListFilesCommand_Construciton_1() { Mock <IIrbisConnection> mock = GetConnectionMock(); IIrbisConnection connection = mock.Object; ListFilesCommand command = new ListFilesCommand(connection); Assert.AreSame(connection, command.Connection); }
public void InvalidArgumentsTest() { ICommand command = new ListFilesCommand(); var commandResult = command.Execute(new List <string>()); Assert.IsNotNull(commandResult); Assert.AreEqual(1, commandResult.Count()); Assert.AreEqual("Invalid arguments", commandResult.First()); }
public void ExecuteTest() { ICommand command = new ListFilesCommand(); var commandResult = command.Execute(null); var fileEntiry = Directory.GetFileSystemEntries(Directory.GetCurrentDirectory()); Assert.IsNotNull(commandResult); Assert.AreEqual(fileEntiry.Length, commandResult.Count()); foreach (var entiry in fileEntiry) { Assert.IsTrue(commandResult.Contains(entiry.Split('\\').Last())); } }
public ListFilesHandler(ListFilesCommand command) { _command = command; }
private async Task <StepResult> DoCopyFileAsync(CopyFileStep step) { IList <FileMetadata> sourceFiles, targetFiles; // List all source files if (step.Direction == FileCopyDirection.RemoteToLocal) { var command = new ListFilesCommand { Path = step.SourcePath, IncludeSubdirectories = step.IncludeSubdirectories }; var response = await _channel.SendWithReplyAsync <ListFilesResponse>(command, _controller.CancellationToken); sourceFiles = response.Files; } else { if (!TryGetLocalMetadata(step.SourcePath, step.IncludeSubdirectories, out sourceFiles, out var error)) { return(new StepResult(false, error, "")); } } if (sourceFiles.Count == 0) { return(new StepResult(false, $"Path \"{step.SourcePath}\" does not exist", "")); } // List all target files if (step.Direction == FileCopyDirection.LocalToRemote) { var command = new ListFilesCommand { Path = step.TargetPath, IncludeSubdirectories = step.IncludeSubdirectories }; var response = await _channel.SendWithReplyAsync <ListFilesResponse>(command, _controller.CancellationToken); targetFiles = response.Files; } else { if (!TryGetLocalMetadata(step.TargetPath, step.IncludeSubdirectories, out targetFiles, out var error)) { return(new StepResult(false, error, "")); } } // Copying one file? if (sourceFiles.Count == 1 && !sourceFiles[0].IsDirectory) { if (targetFiles.Count > 0 && targetFiles[0].IsDirectory) { return(new StepResult(false, $"File \"{step.SourcePath}\" cannot be copied: the target path is a directory.", "")); } if (step.FailIfNotModified && sourceFiles[0].LastWriteTimeUtc == GetInitialFileTimestamp(step.SourcePath)) { return(new StepResult(false, "File was not changed after executing the previous steps. Disable Check Timestamp in step options to skip the modification date check.", "")); } if (step.SkipIfNotModified && targetFiles.Count == 1 && sourceFiles[0].Size == targetFiles[0].Size && sourceFiles[0].LastWriteTimeUtc == targetFiles[0].LastWriteTimeUtc) { return(new StepResult(true, "", "No files were copied. Sizes and modification times are identical on the source and target sides.\r\n")); } return(await DoCopySingleFileAsync(step)); } // Copying a directory? return(await DoCopyDirectoryAsync(step, sourceFiles, targetFiles)); }