public void SkipSuspensionWhenMarketsStateNull()
        {
            //Arrange
            var fixture1 = new Fixture {
                Id = "fixture1Id"
            };

            StateProviderMock.Setup(a =>
                                    a.GetMarketsState(It.IsAny <string>()))
            .Returns((IMarketStateCollection)null);
            var suspensionManager =
                new SuspensionManager(
                    StateProviderMock.Object,
                    AdapterPluginMock.Object);

            //Act
            suspensionManager.Suspend(fixture1);

            //Assert
            StateProviderMock.Verify(o =>
                                     o.GetMarketsState(It.Is <string>(f => f.Equals(fixture1.Id))),
                                     Times.Once);
            AdapterPluginMock.Verify(o =>
                                     o.Suspend(It.Is <string>(f => f.Equals(fixture1.Id))),
                                     Times.Never);
        }
        public void SuspendFixtureThrowsPluginExceptionTest()
        {
            //Arrange
            var fixture1 = new Fixture {
                Id = "fixture1Id"
            };
            var marketStateCollectionMock = new Mock <IMarketStateCollection>();

            marketStateCollectionMock.SetupGet(o => o.FixtureId).Returns(fixture1.Id);
            StateProviderMock.Setup(a =>
                                    a.GetMarketsState(It.IsAny <string>()))
            .Returns(marketStateCollectionMock.Object);
            AdapterPluginMock.Setup(o => o.Suspend(It.Is <string>(f => f.Equals(fixture1.Id)))).Throws <Exception>();
            var suspensionManager =
                new SuspensionManager(
                    StateProviderMock.Object,
                    AdapterPluginMock.Object);

            //Act
            void SuspendCall() => suspensionManager.Suspend(fixture1);

            //Assert
            Assert.Throws <PluginException>(SuspendCall);
            StateProviderMock.Verify(o =>
                                     o.GetMarketsState(It.Is <string>(f => f.Equals(fixture1.Id))),
                                     Times.Once);
            AdapterPluginMock.Verify(o =>
                                     o.Suspend(It.Is <string>(f => f.Equals(fixture1.Id))),
                                     Times.Once);
        }
        public void SuspendFixtureTest()
        {
            //Arrange
            var fixture1 = new Fixture {
                Id = "fixture1Id"
            };
            var marketStateCollectionMock = new Mock <IMarketStateCollection>();

            marketStateCollectionMock.SetupGet(o => o.FixtureId).Returns(fixture1.Id);
            StateProviderMock.Setup(a =>
                                    a.GetMarketsState(It.IsAny <string>()))
            .Returns(marketStateCollectionMock.Object);
            var suspensionManager =
                new SuspensionManager(
                    StateProviderMock.Object,
                    AdapterPluginMock.Object);

            //Act
            suspensionManager.Suspend(fixture1, SuspensionReason.FIXTURE_DISPOSING);
            suspensionManager.Suspend(fixture1, SuspensionReason.SUSPENSION);
            suspensionManager.Suspend(fixture1, SuspensionReason.DISCONNECT_EVENT);
            suspensionManager.Suspend(fixture1, SuspensionReason.FIXTURE_ERRORED);
            suspensionManager.Suspend(fixture1, SuspensionReason.FIXTURE_DELETED);

            //Assert
            StateProviderMock.Verify(o =>
                                     o.GetMarketsState(It.Is <string>(f => f.Equals(fixture1.Id))),
                                     Times.Exactly(5));
            AdapterPluginMock.Verify(o =>
                                     o.Suspend(It.Is <string>(f => f.Equals(fixture1.Id))),
                                     Times.Exactly(4));
            AdapterPluginMock.Verify(o =>
                                     o.ProcessStreamUpdate(It.Is <Fixture>(f => f.Id.Equals(fixture1.Id)), false),
                                     Times.Once);
            AdapterPluginMock.Verify(o =>
                                     o.ProcessStreamUpdate(It.IsAny <Fixture>(), true),
                                     Times.Never);
        }