示例#1
0
        public void RunSynchronously()
        {
            CancellationTokenSource cts = new CancellationTokenSource();
            var delJob = new DeleteJob(new DeleteJobArguments(state.ExistingFiles[0]), state.OnProgressDebugPrint, cts.Token);

            delJob.Run();
            state.ExistingFiles[0].Refresh();

            Assert.IsFalse(state.ExistingFiles[0].Exists);
        }
示例#2
0
        public void DeleteNonEmptyDirectory()
        {
            var cts = new CancellationTokenSource();
            var job = new DeleteJob(new DeleteJobArguments(state.ExistingNonEmptyDirectories[0], true), cts.Token);

            job.Run();

            state.ExistingNonEmptyDirectories[0].Refresh();
            Assert.IsFalse(state.ExistingNonEmptyDirectories[0].Exists);
        }
示例#3
0
        public void TargetDoesNotExist()
        {
            CancellationTokenSource cts = new CancellationTokenSource();
            var delJob = new DeleteJob(
                new DeleteJobArguments(state.NonExistingFiles[0]), state.OnProgressDebugPrint
                , cts.Token);

            try
            {
                delJob.Run();
            }
            catch (DeleteException e)
            {
                state.ExceptionThrown = true;
                Assert.IsTrue(e.InnerException is FileNotFoundException);
            }

            Assert.IsTrue(state.ExceptionThrown);
        }
示例#4
0
        public void TargetWithoutRights()
        {
            CancellationTokenSource cts = new CancellationTokenSource();
            var delJob = new DeleteJob(new DeleteJobArguments(state.ExistentFileWithoutRights), state.OnProgressDebugPrint, cts.Token);

            try
            {
                delJob.Run();
            }
            catch (DeleteException e)
            {
                state.ExceptionThrown = true;
                Assert.IsTrue(e.InnerException is UnauthorizedAccessException);
            }

            state.ExistentFileWithoutRights.Refresh();
            Assert.IsTrue(state.ExistentFileWithoutRights.Exists);
            Assert.IsTrue(state.ExceptionThrown);
        }
示例#5
0
        public void OpenedHandle()
        {
            using (var fs = new FileStream(state.ExistingFiles[0].FullName, FileMode.Open))
            {
                CancellationTokenSource cts = new CancellationTokenSource();
                var delJob = new DeleteJob(new DeleteJobArguments(state.ExistingFiles[0]), state.OnProgressDebugPrint, cts.Token);

                try
                {
                    delJob.Run();
                }
                catch (DeleteException e)
                {
                    state.ExceptionThrown = true;
                    Assert.IsTrue(e.InnerException is IOException);
                }

                Assert.IsTrue(state.ExceptionThrown);

                state.ExistingFiles[0].Refresh();
                Assert.IsTrue(state.ExistingFiles[0].Exists);
            }
        }