本文整理汇总了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();
}
示例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);
}