public void QueueIsFifo() {
     var manager = new Mock<ISyncEventManager>();
     var queue = new SingleStepEventQueue(manager.Object);
     var syncEvent1 = new Mock<ISyncEvent>();
     var syncEvent2 = new Mock<ISyncEvent>();
     queue.AddEvent(syncEvent1.Object);
     queue.AddEvent(syncEvent2.Object);
     queue.Step();
     manager.Verify(m => m.Handle(syncEvent1.Object), Times.Once());
     manager.Verify(m => m.Handle(syncEvent2.Object), Times.Never());
     queue.Step();
     manager.Verify(m => m.Handle(syncEvent1.Object), Times.Once());
     manager.Verify(m => m.Handle(syncEvent2.Object), Times.Once());
 }
        public void QueueIsFifo()
        {
            var manager    = new Mock <ISyncEventManager>();
            var queue      = new SingleStepEventQueue(manager.Object);
            var syncEvent1 = new Mock <ISyncEvent>();
            var syncEvent2 = new Mock <ISyncEvent>();

            queue.AddEvent(syncEvent1.Object);
            queue.AddEvent(syncEvent2.Object);
            queue.Step();
            manager.Verify(m => m.Handle(syncEvent1.Object), Times.Once());
            manager.Verify(m => m.Handle(syncEvent2.Object), Times.Never());
            queue.Step();
            manager.Verify(m => m.Handle(syncEvent1.Object), Times.Once());
            manager.Verify(m => m.Handle(syncEvent2.Object), Times.Once());
        }
 public void EventsGetForwarded() {
     var manager = new Mock<ISyncEventManager>();
     var queue = new SingleStepEventQueue(manager.Object);
     var syncEvent = new Mock<ISyncEvent>();
     queue.AddEvent(syncEvent.Object);
     queue.Step();
     manager.Verify(m => m.Handle(syncEvent.Object), Times.Once());
 }
 public void StartAndStopWorks() {
     var manager = new Mock<ISyncEventManager>();
     var queue = new SingleStepEventQueue(manager.Object);
     var syncEvent = new Mock<ISyncEvent>();
     queue.AddEvent(syncEvent.Object);
     Assert.That(queue.IsStopped, Is.False, "Queue should not start immediatly");
     queue.Step();
     Assert.That(queue.IsStopped, Is.True, "Queue should be Stopped if empty again");
 }
        public void EventsGetForwarded()
        {
            var manager   = new Mock <ISyncEventManager>();
            var queue     = new SingleStepEventQueue(manager.Object);
            var syncEvent = new Mock <ISyncEvent>();

            queue.AddEvent(syncEvent.Object);
            queue.Step();
            manager.Verify(m => m.Handle(syncEvent.Object), Times.Once());
        }
        public void StartAndStopWorks()
        {
            var manager   = new Mock <ISyncEventManager>();
            var queue     = new SingleStepEventQueue(manager.Object);
            var syncEvent = new Mock <ISyncEvent>();

            queue.AddEvent(syncEvent.Object);
            Assert.That(queue.IsStopped, Is.False, "Queue should not start immediatly");
            queue.Step();
            Assert.That(queue.IsStopped, Is.True, "Queue should be Stopped if empty again");
        }
        public void DropAllFSEventsIfConfigured([Values(true, false)] bool dropAll)
        {
            var manager = new SyncEventManager();
            var handler = new Mock <SyncEventHandler>()
            {
                CallBase = true
            };

            handler.Setup(h => h.Priority).Returns(EventHandlerPriorities.CRITICAL);
            var underTest = new SingleStepEventQueue(manager);

            manager.AddEventHandler(handler.Object);

            underTest.DropAllLocalFileSystemEvents = dropAll;
            underTest.AddEvent(Mock.Of <IFSEvent>());
            underTest.AddEvent(Mock.Of <ISyncEvent>());
            underTest.Run();

            handler.Verify(h => h.Handle(It.IsAny <IFSEvent>()), dropAll ? Times.Never() : Times.Once());
            handler.Verify(h => h.Handle(It.IsAny <ISyncEvent>()), dropAll ? Times.Once() : Times.Exactly(2));
        }
        public void DropAllFSEventsIfConfigured([Values(true, false)]bool dropAll) {
            var manager = new SyncEventManager();
            var handler = new Mock<SyncEventHandler>() { CallBase = true };
            handler.Setup(h => h.Priority).Returns(EventHandlerPriorities.CRITICAL);
            var underTest = new SingleStepEventQueue(manager);
            manager.AddEventHandler(handler.Object);

            underTest.DropAllLocalFileSystemEvents = dropAll;
            underTest.AddEvent(Mock.Of<IFSEvent>());
            underTest.AddEvent(Mock.Of<ISyncEvent>());
            underTest.Run();

            handler.Verify(h => h.Handle(It.IsAny<IFSEvent>()), dropAll ? Times.Never() : Times.Once());
            handler.Verify(h => h.Handle(It.IsAny<ISyncEvent>()), dropAll ? Times.Once() : Times.Exactly(2));
        }