Ejemplo n.º 1
0
        public void DeleteHandler()
        {
            const string TEST_FOLDER_NAME = "TestFolderToDelete";
            const string TEST_FOLDER_PATH = ROOT_TEST_PATH + "\\" + TEST_FOLDER_NAME;

            Directory.CreateDirectory(TEST_FOLDER_PATH);

            Assert.True(Directory.Exists(TEST_FOLDER_PATH));

            var param = new DeleteParam
            {
                CurrentFolderPath = "/",
                Targets           = new List <string> {
                    TEST_FOLDER_NAME
                }
            };

            var result = new DeleteHandler(CreateHostingEnv()).Run(param) as DeleteResult;

            PrintErrors(result.Errors);

            Assert.Equal(1, result.Affected);
            Assert.False(Directory.Exists(TEST_FOLDER_PATH));
            Assert.True(result.Errors.Count == 0);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Generating format...");

            #region Params

            var p_copy = new CopyParam
            {
                CurrentFolderPath    = "/",
                SourceDirectory      = "/",
                DestinationDirectory = "/",
                Overwrite            = false,
                Targets = new System.Collections.Generic.List <BaseActionTarget>
                {
                    new BaseActionTarget
                    {
                        IsFile = true,
                        Name   = "sample.txt"
                    }
                }
            };

            var p_move = new MoveParam
            {
                CurrentFolderPath    = "/",
                SourceDirectory      = "/",
                DestinationDirectory = "/",
                Overwrite            = false,
                Targets = new System.Collections.Generic.List <BaseActionTarget>
                {
                    new BaseActionTarget
                    {
                        IsFile = true,
                        Name   = "sample.txt"
                    }
                }
            };

            var p_createFolder = new CreateFolderParam
            {
                CurrentFolderPath = "/",
                Name = "new folder name"
            };

            var p_delete = new DeleteParam
            {
                CurrentFolderPath = "/",
                Targets           = new System.Collections.Generic.List <string>
                {
                    "itemNameToDelete"
                }
            };

            var p_folderStruct = new FolderStructParam
            {
                CurrentFolderPath = "/",
                FileExtensions    = new string[] { ".txt" }
            };

            var p_rename = new RenameParam
            {
                CurrentFolderPath = "/",
                Targets           = new System.Collections.Generic.List <RenameActionTarget>
                {
                    new RenameActionTarget
                    {
                        IsFile  = true,
                        Name    = "new name",
                        OldName = "old name"
                    }
                }
            };

            #endregion

            #region Results

            var r_copy = new CopyResult
            {
                Errors = new System.Collections.Generic.List <string>
                {
                    "Error message."
                }
            };

            var r_move = new MoveResult
            {
                Errors = new System.Collections.Generic.List <string>
                {
                    "Error message."
                }
            };

            var r_createFolder = new CreateFolderResult
            {
                Errors = new System.Collections.Generic.List <string>
                {
                    "Error message."
                }
            };

            var r_delete = new DeleteResult
            {
                Affected = 0,
                Errors   = new System.Collections.Generic.List <string>
                {
                    "Error message."
                }
            };

            var r_folderStruct = new FolderStructResult
            {
                Errors = new System.Collections.Generic.List <string>
                {
                    "Error message."
                },
                Files = new System.Collections.Generic.List <FileInfoProxy>
                {
                    new FileInfoProxy
                    {
                        Name       = "file.name",
                        Properties = new System.Collections.Generic.Dictionary <string, string>
                        {
                            { "Property", "Value" }
                        }
                    }
                },
                Folders = new System.Collections.Generic.List <FileInfoProxy>
                {
                    new FileInfoProxy
                    {
                        Name       = "folder name",
                        Properties = new System.Collections.Generic.Dictionary <string, string>
                        {
                            { "Property", "Value" }
                        }
                    }
                }
            };

            var r_rename = new RenameResult
            {
                Affected = 0,
                Errors   = new System.Collections.Generic.List <string>
                {
                    "Error message."
                },
                RenamedObjects = new System.Collections.Generic.List <RenameActionTarget>()
                {
                    new RenameActionTarget
                    {
                        IsFile  = true,
                        Name    = "new name",
                        OldName = "old name"
                    }
                }
            };

            #endregion

            SaveFormat("p_copy.json", p_copy);
            SaveFormat("p_move.json", p_move);
            SaveFormat("p_createFolder.json", p_createFolder);
            SaveFormat("p_delete.json", p_delete);
            SaveFormat("p_folderStruct.json", p_folderStruct);
            SaveFormat("p_rename.json", p_rename);

            SaveFormat("r_copy.json", r_copy);
            SaveFormat("r_move.json", r_move);
            SaveFormat("r_createFolder.json", r_createFolder);
            SaveFormat("r_delete.json", r_delete);
            SaveFormat("r_folderStruct.json", r_folderStruct);
            SaveFormat("r_rename.json", r_rename);
        }