示例#1
0
        public void OpenedHandle()
        {
            using (var fs = new FileStream(Path.Combine(Path.GetTempPath(), @"existingNonEmptyDirectory1\existingEmptyDirectory1\existingFile1.txt"), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var cts = new CancellationTokenSource();
                var job = new DirectoryTransferJob(
                    new DirectoryTransferArguments(state.ExistingNonEmptyDirectories[0], state.NonExistingDirectories[0], TransferSettings.DeleteOriginal),
                    state.OnProgressDebugPrint
                    ,
                    cts.Token);

                try
                {
                    job.Run();
                }
                catch (DirectoryTransferException e)
                {
                    state.ExceptionThrown = true;
                    //Exceptions reflect file system hierarchy
                    Assert.IsTrue(e.InnerException is DirectoryTransferException);
                    Assert.IsTrue(e.InnerException.InnerException is FileTransferException);
                    Assert.IsTrue(e.InnerException.InnerException.InnerException is IOException);
                }

                Assert.IsTrue(state.ExceptionThrown);

                state.ExistingNonEmptyDirectories[0].Refresh();
                state.NonExistingDirectories[0].Refresh();
                Assert.IsFalse(state.NonExistingDirectories[0].Exists);
                Assert.IsTrue(state.ExistingNonEmptyDirectories[0].Exists);
            }
        }
示例#2
0
        public void SourceWithoutRights()
        {
            var cts = new CancellationTokenSource();
            var job = new DirectoryTransferJob(
                new DirectoryTransferArguments(state.ExistingDirecoryWithoutReadRights, state.NonExistingDirectories[0], TransferSettings.DeleteOriginal),
                state.OnProgressDebugPrint
                ,
                cts.Token);

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

            Assert.IsTrue(state.ExceptionThrown);

            state.ExistingDirecoryWithoutReadRights.Refresh();
            state.NonExistingDirectories[0].Refresh();
            Assert.IsFalse(state.NonExistingDirectories[0].Exists);
            Assert.IsTrue(state.ExistingDirecoryWithoutReadRights.Exists);
        }
示例#3
0
        public void CanceledBeforeAndDestinationDoesExists()
        {
            var cts = new CancellationTokenSource();
            var job = new DirectoryTransferJob(
                new DirectoryTransferArguments(state.ExistingNonEmptyDirectories[0], state.ExistingNonEmptyDirectories[1], TransferSettings.DeleteOriginal),
                state.OnProgressDebugPrint
                ,
                cts.Token);

            cts.Cancel();

            try
            {
                job.Run();
            }
            catch (OperationCanceledException)
            {
                state.ExceptionThrown = true;
            }

            Assert.IsTrue(state.ExceptionThrown);

            state.ExistingNonEmptyDirectories[0].Refresh();
            state.ExistingNonEmptyDirectories[1].Refresh();
            Assert.IsTrue(state.ExistingNonEmptyDirectories[0].Exists);
            Assert.IsTrue(state.ExistingNonEmptyDirectories[1].Exists);

            Assert.IsTrue(state.CheckDirectoryStructure(state.ExistingNonEmptyDirectories[0]));
        }
示例#4
0
        public void DestinationDoesExist()
        {
            var cts = new CancellationTokenSource();
            var job = new DirectoryTransferJob(
                new DirectoryTransferArguments(state.ExistingNonEmptyDirectories[0], state.ExistingEmptyDirectories[0], TransferSettings.DeleteOriginal),
                state.OnProgressDebugPrint
                ,
                cts.Token);

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

            Assert.IsTrue(state.ExceptionThrown);

            state.ExistingNonEmptyDirectories[0].Refresh();
            state.ExistingEmptyDirectories[0].Refresh();
            Assert.IsTrue(state.ExistingNonEmptyDirectories[0].Exists);
            Assert.IsTrue(state.ExistingEmptyDirectories[0].Exists);

            Assert.IsFalse(state.CheckDirectoryStructure(state.ExistingEmptyDirectories[0]));
        }
        public void SourceDoesNotExist()
        {
            var cts = new CancellationTokenSource();
            var job = new DirectoryTransferJob(
                new DirectoryTransferArguments(state.NonExistingDirectories[0], state.NonExistingDirectories[0], TransferSettings.None),
                state.OnProgressDebugPrint
                ,
                cts.Token);

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


            Assert.IsTrue(state.ExceptionThrown);

            state.NonExistingDirectories[0].Refresh();
            Assert.IsFalse(state.NonExistingDirectories[0].Exists);
        }
        public void RunSynchronously()
        {
            var cts = new CancellationTokenSource();
            var job = new DirectoryTransferJob(
                new DirectoryTransferArguments(state.ExistingEmptyDirectories[0], state.NonExistingDirectories[0], TransferSettings.None),
                state.OnProgressDebugPrint
                ,
                cts.Token);

            job.Run();

            state.NonExistingDirectories[0].Refresh();
            Assert.IsTrue(state.NonExistingDirectories[0].Exists);
        }
示例#7
0
        public void RunSynchronouslyNonEmpty()
        {
            var cts = new CancellationTokenSource();
            var job = new DirectoryTransferJob(
                new DirectoryTransferArguments(state.ExistingNonEmptyDirectories[0], state.NonExistingDirectories[0], TransferSettings.DeleteOriginal),
                state.OnProgressDebugPrint
                ,
                cts.Token);

            job.Run();

            state.NonExistingDirectories[0].Refresh();
            state.ExistingNonEmptyDirectories[0].Refresh();
            Assert.IsTrue(state.NonExistingDirectories[0].Exists);
            Assert.IsFalse(state.ExistingNonEmptyDirectories[0].Exists);

            Assert.IsTrue(state.CheckDirectoryStructure(state.NonExistingDirectories[0]));
        }