public void WhenExecuteCommandWithValidFile_CommandManager_ShouldZipDirectory() { var path = "myPath"; var storedDataService = new StoredDataServiceMock(false); var fileServiceMock = new FileServiceMock() { IsDirectoryReturn = false }; var commandDefinition = new ZipCommand(fileServiceMock); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandPathParameter.GetInvokeName(), path); instance.ExecuteInputRequest(inputRequest); var expected = path; var actual = fileServiceMock.ZippedPath; Assert.Equal(expected, actual); }
public void TestTrueCase() { var cmd = new ZipCommand(_filePath, Path.GetFullPath(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))); var stat = cmd.DoCommand(); Assert.That(_filePath, Is.Not.Null); Assert.That(stat.Status, Is.EqualTo(0), stat.Error); Assert.That(File.Exists(_filePath)); Assert.That(stat.Output, Contains.Substring("Successfully zipped")); }
public void TestIfAnyOfInputFilesAreEmpty_ReturnsErrorStatus() { var cmd = new ZipCommand(_filePath, new[] { "d", Path.GetRandomFileName() }.PathJoin()); var stat = cmd.DoCommand(); Assert.That(File.Exists(_filePath)); Assert.That(stat.Status, Is.EqualTo(-1)); Assert.That(stat.Error, Is.Not.Empty); Assert.That(stat.Output, Is.Empty); }
public ZipViewModel(ZipModel zipModel) { _zipModel = zipModel; _filePicker = InitFilePicker(); _folderPicker = new FolderPicker(); _folderPicker.ViewMode = PickerViewMode.List; _folderPicker.FileTypeFilter.Add("*"); // commands initialized ZipCommand = new ZipCommand(() => Compress(), () => true); FolderSelectCommand = new ZipCommand(() => SelectFolderToZip(), () => true); FilesSelectCommand = new ZipCommand(() => SelectMultipleFile(), () => true); //CompressionLevelChange = new ZipCommand(()=>SetCompressionLevel(SelectedItem),()=>true); }
public void WhenExecuteCommandWithoutPathParameter_CommandManager_ShouldThrowException() { var storedDataService = new StoredDataServiceMock(false); var fileServiceMock = new FileServiceMock(); var commandDefinition = new ZipCommand(fileServiceMock); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName()); Assert.Throws <InvalidParamsException>(() => { instance.ExecuteInputRequest(inputRequest); }); }