public void Execute_FolderContainsSubFoldersWithFiles_SubFolderFilesDeleted()
        {
            var folder1 = MockRepository.GenerateMock <IFolder>();

            folder1.Stub(f => f.GetSubFolderList()).Return(new List <IFolder>());
            var file = MockRepository.GenerateMock <IFile>();

            folder1.Stub(f => f.GetFileList()).Return(new List <IFile>()
            {
                file
            });

            FakeFolder folder = new FakeFolder(@"fakeFolder");

            folder.FolderExistsReturnValue = true;
            folder.SubFolderList           = new List <IFolder>()
            {
                folder1,
            };

            ICommand deleteComand = new DeleteFolderCommand(folder);

            deleteComand.Execute();

            file.AssertWasCalled(f => f.Delete());
        }
        public void Execute_folder_does_not_exist_delete_not_called()
        {
            FakeFolder folder = new FakeFolder(@"c:\fakeFolder\");

            folder.FolderExistsReturnValue = false;

            ICommand deleteCommand = new DeleteFolderCommand(folder);

            deleteCommand.Execute();

            Assert.IsFalse(folder.DeleteFolderCalled);
        }
        public void Execute_Folder_deleted()
        {
            FakeFolder folder = new FakeFolder(@"c:\fakeFolder\");

            folder.FolderExistsReturnValue = true;

            ICommand deleteCommand = new DeleteFolderCommand(folder);

            deleteCommand.Execute();

            Assert.IsTrue(folder.DeleteFolderCalled);
        }
示例#4
0
        public async Task <DeleteFolderResult> DeleteFoldersAsync(IEnumerable <EwsFolderIdentifier> identifiers)
        {
            var parameter = new DeleteFolderParameter();

            parameter.Identifiers.AddRange(identifiers);

            var command = new DeleteFolderCommand(parameter, this.settings);

            var result = await command.Execute();

            return(result.Data);
        }
        public void Undo_Creates_folder_when_undo_is_called_after_execute()
        {
            FakeFolder folder = new FakeFolder(@"c:\fakeFolder\");

            folder.FolderExistsReturnValue = true;

            ICommand deleteCommand = new DeleteFolderCommand(folder);

            deleteCommand.Execute();
            deleteCommand.Undo();

            Assert.IsTrue(folder.CreateFolderCalled);
        }
        public void Execute_Folder_contains_files_files_delete_first()
        {
            FakeFolder folder = new FakeFolder(@"fakeFolder");

            folder.FolderExistsReturnValue = true;
            folder.FileList = new List <IFile>()
            {
                new FakeFile("file1"),
                new FakeFile("file2"),
            };

            ICommand deleteComand = new DeleteFolderCommand(folder);

            deleteComand.Execute();

            Assert.IsTrue(folder.FileList.TrueForAll(f => ((FakeFile)f).DeleteCalled), "Not all the files were deleted before trying to delete the folder!");
        }
        public void Execute_folder_contains_readonly_files_readonly_attribute_cleared()
        {
            FakeFolder folder = new FakeFolder(@"fakeFolder");

            folder.FolderExistsReturnValue = true;
            folder.FileList = new List <IFile>()
            {
                new FakeFile("file1")
                {
                    Attributes = System.IO.FileAttributes.ReadOnly
                },
                new FakeFile("file2")
                {
                    Attributes = System.IO.FileAttributes.ReadOnly
                },
            };

            ICommand command = new DeleteFolderCommand(folder);

            command.Execute();
            Assert.IsTrue(folder.FileList.TrueForAll(f => ((FakeFile)f).Attributes == System.IO.FileAttributes.Normal));
        }