コード例 #1
0
        public void itShouldSucceedIfSourceDiretoryDoesNotExist()
        {
            var fileSysCommand   = new MockFileSystemCommand();
            var dirToDelete      = @"c:\dummyDir";
            var dirDeleteCommand = new DirectoryDeleteCommand(dirToDelete, @"c:\dummybackupdir", fileSysCommand);
            var fakeFileSystem   = new FakeFileSystem(fileSysCommand);

            dirDeleteCommand.Do();
            Assert.IsTrue(dirDeleteCommand.DidCommandSucceed);
        }
コード例 #2
0
        public void itShouldRestoreBackupOnUndo()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);
            var dirToDelete    = @"c:\mainFolder\dummysourcedir";

            fakeFileSystem.AddDirectory(dirToDelete);
            var dirDeleteCommand = new DirectoryDeleteCommand(dirToDelete, @"c:\dummybackupdir", fileSysCommand);

            dirDeleteCommand.Do();
            Assert.IsFalse(fakeFileSystem.DirectoryExists(dirToDelete));

            dirDeleteCommand.Undo();
            Assert.IsTrue(fakeFileSystem.DirectoryExists(dirToDelete));
        }
コード例 #3
0
        public void itShouldDeleteBackupFileOnCleanup()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            var dirToDelete = @"c:\main1\main2\dummysourceDir";

            fakeFileSystem.AddDirectory(dirToDelete);
            var dirDeleteCommand = new DirectoryDeleteCommand(dirToDelete, @"c:\dummybackupdir", fileSysCommand);

            dirDeleteCommand.Do();
            dirDeleteCommand.Cleanup();

            Assert.IsFalse(fakeFileSystem.DirectoryExists(dirDeleteCommand.BackedUpDirectory));
        }
コード例 #4
0
        public void itShouldFailIfDeleteFails()
        {
            var fileSysCommand   = new MockFileSystemCommand();
            var sourceDir        = @"c:\dummysourcefile";
            var dirDeleteCommand = new DirectoryDeleteCommand(sourceDir, @"c:\dummybackupdir", fileSysCommand);
            var fakeFileSystem   = new FakeFileSystem(fileSysCommand);

            fileSysCommand.DirectoryDeleteFunc = (filename) => {
                throw new ApplicationException("Exception raised by MockFileSystemCommand during FileDelete");
            };
            fakeFileSystem.AddDirectory(sourceDir);

            dirDeleteCommand.Do();
            Assert.IsFalse(dirDeleteCommand.DidCommandSucceed);
            Assert.IsTrue(fakeFileSystem.DirectoryExists(sourceDir));
        }
コード例 #5
0
        public void itShouldFailIfBackupFails()
        {
            var fileSysCommand   = new MockFileSystemCommand();
            var sourceDir        = @"c:\dummysourceDir";
            var dirDeleteCommand = new DirectoryDeleteCommand(sourceDir, @"c:\dummybackupdir", fileSysCommand);
            var fakeFileSystem   = new FakeFileSystem(fileSysCommand);

            fileSysCommand.DirectoryCopyContentsFunc = (sourceFile, destinationFile, preCopyCallback, postCopyCallback) => {
                throw new ApplicationException("Exception raised by MockFileSystemCommand during DirectoryCopy");
            };
            fakeFileSystem.AddDirectory(sourceDir);

            dirDeleteCommand.Do();

            Assert.IsFalse(dirDeleteCommand.DidCommandSucceed);
            Assert.IsTrue(fakeFileSystem.DirectoryExists(sourceDir));
        }