当前位置: 首页>>代码示例>>C#>>正文


C# StateManager.CreateNewMarketRuleManager方法代码示例

本文整理汇总了C#中StateManager.CreateNewMarketRuleManager方法的典型用法代码示例。如果您正苦于以下问题:C# StateManager.CreateNewMarketRuleManager方法的具体用法?C# StateManager.CreateNewMarketRuleManager怎么用?C# StateManager.CreateNewMarketRuleManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StateManager的用法示例。


在下文中一共展示了StateManager.CreateNewMarketRuleManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MarkMarkedAsForcedSuspended

        public void MarkMarkedAsForcedSuspended()
        {
            Mock<IResourceFacade> resource = new Mock<IResourceFacade>();
            Mock<IAdapterPlugin> connector = new Mock<IAdapterPlugin>();
            Mock<IEventState> state = new Mock<IEventState>();
            
            _settings.Setup(x => x.DeltaRuleEnabled).Returns(true);
            var provider = new StateManager(_settings.Object, connector.Object);
            
            provider.SuspensionManager.RegisterAction(provider.SuspensionManager.SuspendAllMarketsStrategy, SuspensionReason.SUSPENSION);

            //var suspended = false;
            //Action<IMarketStateCollection> suspension_strategy = x => {suspended = true;};
            //suspension.RegisterAction(suspension_strategy, SuspensionReason.FIXTURE_DELETED);

            // Please note Sequence = 1
            Fixture fixture = new Fixture { Id = "ABCDE", Sequence = 1, MatchStatus = ((int)MatchStatus.InRunning).ToString(), Epoch = 1 };

            Market mkt = new Market { Id = "MKT" };

            fixture.Markets.Add(mkt);

            // ...and Sequence = 3
            Fixture update = new Fixture
            {
                Id = "ABCDE",
                Sequence = 2,
                MatchStatus = ((int)MatchStatus.MatchOver).ToString(),
                Epoch = 2,
                LastEpochChangeReason = new[] { (int)EpochChangeReason.BaseVariables }
            };

            StreamMessage message = new StreamMessage { Content = update };

            resource.Setup(x => x.Id).Returns("ABCDE");
            resource.Setup(x => x.Content).Returns(new Summary());
            resource.Setup(x => x.MatchStatus).Returns(MatchStatus.InRunning);
            resource.Setup(x => x.StartStreaming()).Raises(x => x.StreamConnected += null, EventArgs.Empty);
            resource.Setup(x => x.GetSnapshot()).Returns(FixtureJsonHelper.ToJson(fixture));

            // STEP 2: start the listener
            StreamListener listener = new StreamListener(resource.Object, connector.Object, state.Object, provider,_settings.Object);

            listener.Start();

            listener.IsStreaming.Should().BeTrue();


            //Update snapshot sequence
            fixture.Sequence = 2;
            resource.Setup(x => x.GetSnapshot()).Returns(FixtureJsonHelper.ToJson(fixture));

            // STEP 3: let create at lea
            listener.ResourceOnStreamEvent(this, new StreamEventArgs(JsonConvert.SerializeObject(message)));

            var fixtureState = provider.CreateNewMarketRuleManager("ABCDE").CurrentState;
            fixtureState.Markets.All(x => fixtureState[x].IsForcedSuspended).Should().BeFalse();
        }
开发者ID:luxbet,项目名称:SS.Integration.Adapter,代码行数:58,代码来源:StreamListenerTests.cs

示例2: DeltaRuleWithRealFixtureTest

        public void DeltaRuleWithRealFixtureTest()
        {
            var settings = new Mock<ISettings>();
            var plugin = new Mock<IAdapterPlugin>();
            var state = new StateManager(settings.Object, plugin.Object);

            DeltaRule.Instance.Severity = DeltaRule.DeltaRuleSeverity.REMOVE_SELECTIONS;
            List<IMarketRule> rules = new List<IMarketRule> {DeltaRule.Instance};
            state.ClearState("nr7B1f7gjMuk2ggCJoMIizHKrfI");
            var manager = state.CreateNewMarketRuleManager("nr7B1f7gjMuk2ggCJoMIizHKrfI");
            state.AddRules(rules);

            Fixture fixture = TestHelper.GetFixtureFromResource("rugbydata_snapshot_2");

            int mkt_count = fixture.Markets.Count;
            mkt_count.Should().BeGreaterThan(0);

            // first apply should do anything as there is no state
            manager.ApplyRules(fixture);

            fixture.Markets.Count().Should().Be(mkt_count);

            // from now on, we have a state
            manager.CommitChanges();

            Fixture snapshot = TestHelper.GetFixtureFromResource("rugbydata_snapshot_4");

            manager.ApplyRules(snapshot);
            manager.CommitChanges();

            // snapshot 2 and snapshot-4 have no difference, so everything should have been
            // remove by the delta rule
            snapshot.Markets.Count().Should().Be(0); 

        }
开发者ID:luxbet,项目名称:SS.Integration.Adapter,代码行数:35,代码来源:MarketsFilterTests.cs


注:本文中的StateManager.CreateNewMarketRuleManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。