public void InitializeServiceTest()
        {
            eventManagerMock.Subscribe(typeof(CvsReaderHostedService.IntervalSync), null);
            LastCall.IgnoreArguments();
            connectorMock.Error += null;
            LastCall.IgnoreArguments();

            repository.ReplayAll();

            var service = new CvsReaderHostedService();
            service.Initialize(CreateConfigNode(), eventManagerMock, profileMock);
            Assert.AreEqual(service.Connector, connectorMock);

            repository.VerifyAll();
        }
        public void HandleConnectorErrorTest()
        {
            var connectorException = new Exception();
            var publishObject = new object();

            eventManagerMock.Subscribe(typeof(CvsReaderHostedService.IntervalSync), null);
            LastCall.IgnoreArguments();
            connectorMock.Error += null;
            LastCall.IgnoreArguments();
            IEventRaiser eventRaiser = LastCall.GetEventRaiser();
            eventManagerMock.Publish(publishObject);
            LastCall.IgnoreArguments();

            repository.ReplayAll();

            var service = new CvsReaderHostedService();
            service.Initialize(CreateConfigNode(), eventManagerMock, profileMock);
            eventRaiser.Raise(connectorMock, new ExceptionEventArgs(connectorException));

            repository.VerifyAll();
        }
        public void OnIntervalTest()
        {
            var publishObject = new CvsReaderHostedService.IntervalSync();
            var profileInnerMock = repository.StrictMock<IProfile>();

            var eventManager = new TestEventManager();
            List<CvsChange> changes = CreateSingleEntryListOfChanges();
            List<CvsChangeSet> changeSets = CreateSingleEntryListOfChangesets(changes);
            List<ChangeSetInfo> changeSetInfos = CreateChangeSetInfos(changeSets);

            using(repository.Ordered()) {
                connectorMock.Error += null;
                LastCall.IgnoreArguments();

                Expect.Call(profileMock[CvsReaderHostedService.LastQueryDateKey]).Return(profileInnerMock);
                Expect.Call(profileInnerMock.Value).PropertyBehavior().IgnoreArguments().Return(null).Repeat.Once();

                connectorMock.RunLogCommand(DateTime.Now, DateTime.Now);
                LastCall.IgnoreArguments();

                Expect.Call(logParserMock.Parse()).Return(changes);

                Expect.Call(processorMock.Group(changes)).Return(changeSets);
                Expect.Call(processorMock.Transform(changeSets)).Return(changeSetInfos);

                Expect.Call(profileMock[CvsReaderHostedService.LastQueryDateKey]).Return(profileInnerMock);
            }

            repository.ReplayAll();

            var service = new CvsReaderHostedService();
            service.Initialize(CreateConfigNode(), eventManager, profileMock);
            eventManager.Publish(publishObject);
            Assert.AreEqual(eventManager.Changes.Count, 1);

            repository.VerifyAll();
        }