public void AddFailedSyncItem_CalledWithDeleteDirectorySyncItem_FailedDeleteDirectoriesContainsItem()
        {
            DeleteDirectorySyncItem syncItem = new DeleteDirectorySyncItem(" ");

            this.target.AddFailedSyncItem(syncItem);

            var failedDeleteDirectories = this.target.FailedDeleteDirectories;

            Assert.IsTrue(failedDeleteDirectories.Count() == 1, "SyncReport contains wrong number of FailedDeleteDirectories.");
            Assert.ReferenceEquals(syncItem, failedDeleteDirectories.ElementAt(0));
        }
Example #2
0
        public void AddFailedSyncItem_CalledWithDeleteDirectorySyncItem_DeleteDirectorySyncItemsContainsItem()
        {
            DeleteDirectorySyncItem syncItem = new DeleteDirectorySyncItem(" ");

            this.target.Add(syncItem);

            var deleteDirectorySyncItems = this.target.DeleteDirectorySyncItems;

            Assert.IsTrue(deleteDirectorySyncItems.Count() == 1, "SyncTaskPreview contains wrong number of DeleteDirectorySyncItems.");
            Assert.AreEqual(1, this.target.Count, "SyncTaskPreview contains wrong number of elements.");
            Assert.ReferenceEquals(syncItem, deleteDirectorySyncItems.ElementAt(0));
        }
Example #3
0
        public void RemoveUnnecessarySyncItemsTest_CalledWithNotRemovedDirectory_DirectoriesAreNotRemoved()
        {
            DeleteDirectorySyncItem syncItem1 = new DeleteDirectorySyncItem(directory_base);

            this.target.Add(syncItem1);

            this.target.RemoveUnnecessarySyncItems();

            var deleteDirectorySyncItems = this.target.DeleteDirectorySyncItems;

            Assert.IsTrue(deleteDirectorySyncItems.Count() == 1, "SyncTaskPreview contains wrong number of DeleteDirectorySyncItems.");
            Assert.AreEqual(1, this.target.Count, "SyncTaskPreview contains wrong number of elements.");
        }
Example #4
0
        public void RemoveUnnecessarySyncItemsTest_CalledWithNotRemovedFiles_DirectoriesArePartiallyRemoved()
        {
            DeleteDirectorySyncItem syncItem1 = new DeleteDirectorySyncItem(directory_test);
            DeleteDirectorySyncItem syncItem2 = new DeleteDirectorySyncItem(directory_testtest);

            this.target.Add(syncItem1);
            this.target.Add(syncItem2);

            this.target.RemoveUnnecessarySyncItems();

            var deleteDirectorySyncItems = this.target.DeleteDirectorySyncItems;

            Assert.IsTrue(deleteDirectorySyncItems.Count() == 1, "SyncTaskPreview contains wrong number of DeleteDirectorySyncItems.");
            Assert.ReferenceEquals(syncItem1, deleteDirectorySyncItems.ElementAt(0));
            Assert.AreEqual(1, this.target.Count, "SyncTaskPreview contains wrong number of elements.");
        }
Example #5
0
        public void RemoveUnnecessarySyncItemsTest_CalledWithRemovedFilesAndDirectories_DirectoriesAreRemoved()
        {
            DeleteDirectorySyncItem syncItem1 = new DeleteDirectorySyncItem(directory_test);
            DeleteDirectorySyncItem syncItem2 = new DeleteDirectorySyncItem(directory_testtest);
            DeleteFileSyncItem      syncItem3 = new DeleteFileSyncItem(file1);
            DeleteFileSyncItem      syncItem4 = new DeleteFileSyncItem(file2);

            this.target.Add(syncItem1);
            this.target.Add(syncItem2);
            this.target.Add(syncItem3);
            this.target.Add(syncItem4);

            this.target.RemoveUnnecessarySyncItems();

            var deleteDirectorySyncItems = this.target.DeleteDirectorySyncItems;

            Assert.IsTrue(deleteDirectorySyncItems.Count() == 0, "SyncTaskPreview contains wrong number of DeleteDirectorySyncItems.");
            Assert.AreEqual(2, this.target.Count, "SyncTaskPreview contains wrong number of elements.");
        }
Example #6
0
        /// <summary>
        /// Adds the specified sync item.
        /// </summary>
        /// <param name="syncItem">The sync item.</param>
        internal void Add(SyncItemBase syncItem)
        {
            CopyFileSyncItem copyFileSyncItem = syncItem as CopyFileSyncItem;

            if (copyFileSyncItem != null)
            {
                this.copyFileSyncItems.Add(copyFileSyncItem);
                return;
            }

            DeleteFileSyncItem deleteFileSyncItem = syncItem as DeleteFileSyncItem;

            if (deleteFileSyncItem != null)
            {
                this.deleteFileSyncItems.Add(deleteFileSyncItem);
                return;
            }

            CreateDirectorySyncItem createDirectorySyncItem = syncItem as CreateDirectorySyncItem;

            if (createDirectorySyncItem != null)
            {
                this.createDirectorySyncItems.Add(createDirectorySyncItem);
                return;
            }

            DeleteDirectorySyncItem deleteDirectorySyncItem = syncItem as DeleteDirectorySyncItem;

            if (deleteDirectorySyncItem != null)
            {
                this.deleteDirectorySyncItems.Add(deleteDirectorySyncItem);
                return;
            }

            throw new ArgumentException("SyncItem has invalid type.", "syncItem");
        }