Inheritance: IPollingHost
コード例 #1
0
 public void StopCallsStopOnEachProcessor()
 {
     var mockPro1 = new Mock<IPollProcessor>();
     var mockPro2 = new Mock<IPollProcessor>();
     var host = new PollingHost(new[] { mockPro1.Object, mockPro2.Object });
     var counter1 = AssemblyLoggerProvider.MockLogger.StartCounting(x => x.Info("Stopping"));
     var counter2 = AssemblyLoggerProvider.MockLogger.StartCounting(x => x.Info("Stopped"));
     host.Stop();
     mockPro1.Verify(x => x.Stop(), Times.Once());
     mockPro2.Verify(x => x.Stop(), Times.Once());
     Assert.AreEqual(1, counter1.Count);
     Assert.AreEqual(1, counter2.Count);
 }
コード例 #2
0
 public void BehaviourWhenProcessorThrowsOnStart()
 {
     var exCount = 0;
     var mockPro1 = new Mock<IPollProcessor>();
     mockPro1.Setup(x => x.Start()).Throws(new InvalidOperationException());
     var mockPro2 = new Mock<IPollProcessor>();
     try
     {
         var host = new PollingHost(new[] { mockPro1.Object, mockPro2.Object });
         host.Start();
     }
     catch (InvalidOperationException)
     {
         ++exCount;
     }
     mockPro1.Verify(x => x.Start(), Times.Once());
     mockPro2.Verify(x => x.Start(), Times.Never());
     mockPro2.Verify(x => x.Stop(), Times.AtLeast(2));
     mockPro1.Verify(x => x.Stop(), Times.AtLeast(2));
     AssemblyLoggerProvider.MockLogger.Verify(x => x.Error(It.IsAny<string>(), It.IsAny<Exception>()), Times.AtLeastOnce());
     Assert.AreEqual(1, exCount);
 }