Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
            });
        }