Esempio n. 1
0
        public List <List <AbstractFolderEvent> > Detect(CrawlEventCollection collection)
        {
            var result = new List <List <AbstractFolderEvent> >();

            if (collection.mergableEvents == null)
            {
                return(result);
            }

            foreach (var ev in collection.mergableEvents)
            {
                var item = ev.Value.Item1 ?? ev.Value.Item2;
                if (item.Local == MetaDataChangeType.MOVED ||
                    item.Remote == MetaDataChangeType.MOVED ||
                    item.Local == MetaDataChangeType.CHANGED ||
                    item.Remote == MetaDataChangeType.CHANGED)
                {
                    string process  = ev.Key;
                    string resource = item.RemotePath;
                    if (item is FileEvent)
                    {
                        var fileEvent = item as FileEvent;
                    }
                    else if (item is FolderEvent)
                    {
                        var folderEvent = item as FolderEvent;
                    }
                }
            }

            return(result);
        }
        public void NoNotificationIsCreatedAndCallFailsIfEmptyStructIsPassed()
        {
            CrawlEventCollection emptyCollection = new CrawlEventCollection();

            Assert.Throws <ArgumentNullException>(() => this.underTest.MergeEventsAndAddToQueue(emptyCollection));

            this.queue.Verify(q => q.AddEvent(It.IsAny <ISyncEvent>()), Times.Never());
        }
 public void SetUp()
 {
     this.queue      = new Mock <ISyncEventQueue>();
     this.underTest  = new CrawlEventNotifier(this.queue.Object);
     this.collection = new CrawlEventCollection()
     {
         creationEvents = new List <AbstractFolderEvent>(),
         mergableEvents = new Dictionary <string, Tuple <AbstractFolderEvent, AbstractFolderEvent> >()
     };
 }
        public void NoNotificationIsCreatedIfAllEventsAreEmpty()
        {
            CrawlEventCollection emptyCollection = new CrawlEventCollection()
            {
                creationEvents = new List <AbstractFolderEvent>(),
                mergableEvents = new Dictionary <string, Tuple <AbstractFolderEvent, AbstractFolderEvent> >()
            };

            this.underTest.MergeEventsAndAddToQueue(emptyCollection);

            this.queue.Verify(q => q.AddEvent(It.IsAny <ISyncEvent>()), Times.Never());
        }
        public void LinearRenames()
        {
            string objectId   = Guid.NewGuid().ToString();
            var    collection = new CrawlEventCollection();

            collection.mergableEvents = new Dictionary <string, Tuple <AbstractFolderEvent, AbstractFolderEvent> >();
            var       doc1   = Mock.Of <IFileInfo>(d => d.Name == "C" && d.Uuid == Guid.NewGuid());
            var       doc2   = Mock.Of <IDocument>(d => d.Name == "B" && d.Id == objectId);
            FileEvent event1 = new FileEvent(doc1, null);
            FileEvent event2 = new FileEvent(null, doc2);

            collection.mergableEvents.Add(objectId, new Tuple <AbstractFolderEvent, AbstractFolderEvent>(event1, event2));
            Assert.That(underTest.Detect(collection), Is.Empty);
        }