public void Execute_FileIsNotReadOnly_FileDeleted()
        {
            var fileToDelete = new FakeFile("fileToDelete");

            fileToDelete.ExistsReturnValue = true;
            var deleteCommand = new DeleteFileCommand(fileToDelete);

            deleteCommand.Execute();

            Assert.IsTrue(fileToDelete.DeleteCalled);
        }
        public void Execute_FileDoesNotExist_NoFileDeleteIsCalled()
        {
            var fileToDelete = new FakeFile("fileToDelete");

            fileToDelete.ExistsReturnValue = false;
            fileToDelete.Attributes        = FileAttributes.ReadOnly;

            var deleteCommand = new DeleteFileCommand(fileToDelete);

            deleteCommand.Execute();

            Assert.IsFalse(fileToDelete.DeleteCalled);
        }
        public void Execute_FileIsReadOnly_ReadonlyCleared()
        {
            var fileToDelete = new FakeFile("fileToDelete");

            fileToDelete.ExistsReturnValue = true;
            fileToDelete.Attributes        = FileAttributes.ReadOnly;

            var deleteCommand = new DeleteFileCommand(fileToDelete);

            deleteCommand.Execute();

            Assert.AreEqual(FileAttributes.Normal, fileToDelete.Attributes);
        }
Ejemplo n.º 4
0
        private void CopyModel(ICommandAdapter adapter, string binPath, string model, string modelFile)
        {
            var    copyFileCommand   = new CopyFileCommand();
            string destinationFile   = Path.Combine(binPath, model);
            var    deleteFileCommand = new DeleteFileCommand();

            deleteFileCommand.Parameters.MainParameter = new MainParameter(destinationFile);
            deleteFileCommand.Execute(adapter);
            copyFileCommand.Execute(adapter, _testParameters, modelFile, destinationFile);
            if (this.ParameterValue <ModelOperation>(Operation) != ModelOperation.None)
            {
                var actionCommand = new ActionCommand();
                actionCommand.DoAction(adapter, "Parameter", Path.GetFileNameWithoutExtension(model));
                actionCommand.DoAction(adapter, "EasyTestAction", this.ParameterValue <ModelOperation>(Operation).ToString());
            }
        }
Ejemplo n.º 5
0
 private void CopyModel(ICommandAdapter adapter, string binPath, string model, string modelFile){
     var copyFileCommand = new CopyFileCommand();
     string destinationFile = Path.Combine(binPath, model);
     var deleteFileCommand = new DeleteFileCommand();
     deleteFileCommand.Parameters.MainParameter = new MainParameter(destinationFile);
     deleteFileCommand.Execute(adapter);
     copyFileCommand.Execute(adapter, _testParameters, modelFile, destinationFile);
     if (this.ParameterValue<bool>(IsExternalModel)){
         var actionCommand = new ActionCommand();
         actionCommand.Parameters.MainParameter = new MainParameter("Parameter");
         actionCommand.Parameters.ExtraParameter = new MainParameter(Path.GetFileNameWithoutExtension(model));
         actionCommand.Execute(adapter);
         actionCommand = new ActionCommand();
         actionCommand.Parameters.MainParameter = new MainParameter("Action");
         actionCommand.Parameters.ExtraParameter=new MainParameter("LoadModel");
         actionCommand.Execute(adapter);
     }
 }
Ejemplo n.º 6
0
        public IActionResult DeleteFile(int id, [FromServices] DeleteFileCommand delFileCommand)
        {
            var model = new DeleteFileModel();

            model.Id = id;
            var file = _dataContext.Photos
                       .Include(p => p.ParentFolder)
                       .FirstOrDefault(p => p.Id == id);

            var parentId = file.ParentFolder?.Id;

            delFileCommand.Execute(model);
            if (parentId == null)
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Details", new { id = parentId }));
        }
Ejemplo n.º 7
0
        private void CopyModel(ICommandAdapter adapter, TestAlias testAlias, string model, string modelFile)
        {
            var    copyFileCommand   = new CopyFileCommand();
            string path1             = testAlias.Value;
            string destinationFile   = Path.Combine(path1, model);
            var    deleteFileCommand = new DeleteFileCommand();

            deleteFileCommand.Parameters.MainParameter = new MainParameter(destinationFile);
            deleteFileCommand.Execute(adapter);
            copyFileCommand.Execute(adapter, _testParameters, modelFile, destinationFile);
            if (this.ParameterValue <bool>(IsExternalModel))
            {
                var actionCommand = new ActionCommand();
                actionCommand.Parameters.MainParameter  = new MainParameter("Parameter");
                actionCommand.Parameters.ExtraParameter = new MainParameter(Path.GetFileNameWithoutExtension(model));
                actionCommand.Execute(adapter);
                actionCommand = new ActionCommand();
                actionCommand.Parameters.MainParameter  = new MainParameter("Action");
                actionCommand.Parameters.ExtraParameter = new MainParameter("LoadModel");
                actionCommand.Execute(adapter);
            }
        }
Ejemplo n.º 8
0
 public void Delete(string path)
 {
     _deleteFile.Execute(path);
 }