public void CreateScenarioFromJson() { var scenario = ScenarioDescription.FromJson("scenario", @"[{'action':'Step2'}]", typeof(TestHost)); Assert.AreEqual(1, scenario.Steps.Count); Assert.AreEqual(nameof(TestHost.Step2), scenario.Steps.First().Method.Name); }
public void ExecutionSequenceByJson() { var scenario = ScenarioDescription.FromJson("scenario1", @"[{'action':'Step2'}, {'action':'FailedStep'}]", typeof(TestHost)); var result = new ScenarioResult(scenario); var testContext = new ScenarioContext(); testContext["sequence"] = 1; result.Run(testContext); Assert.AreEqual(2, (int)testContext[nameof(TestHost.FailedStep)], scenario.Description); Assert.AreEqual(1, (int)testContext[nameof(TestHost.Step2)], scenario.Description); // change sequence and make sure that it is different this time scenario = ScenarioDescription.FromJson("scenario2", @"[{'action':'FailedStep'}, {'action':'Step2'}]", typeof(TestHost)); result = new ScenarioResult(scenario); testContext = new ScenarioContext(); testContext["sequence"] = 1; result.Run(testContext); Assert.AreEqual(1, (int)testContext[nameof(TestHost.FailedStep)], scenario.Description); Assert.AreEqual(2, (int)testContext[nameof(TestHost.Step2)], scenario.Description); }