public void CallStaticVoidMethod2ToAndFromJson() { var ruleBefore = MethodCallRulesFactory.CreateStaticVoidMethodCallRule("SomeVoidStaticMethod", "ModelForUnitTests.Game", new List <Rule> { new ConstantRule <int> { Value = "99" } }); var jsonConverterForRule = new JsonConverterForRule(); // convert to json var ruleJson = JsonConvert.SerializeObject(ruleBefore, jsonConverterForRule); _testOutputHelper.WriteLine($"ruleJson:{Environment.NewLine}{ruleJson}"); // read from json var ruleAfter = JsonConvert.DeserializeObject <Rule>(ruleJson, jsonConverterForRule); var compileResult = ruleAfter.Compile(); compileResult.Should().BeTrue(); _testOutputHelper.WriteLine($"rule: {Environment.NewLine}" + $"{ruleAfter.ExpressionDebugView()}"); Game.SomeStaticIntValue = 0; (ruleAfter as StaticVoidMethodCallRule)?.Execute(); Game.SomeStaticIntValue.Should().Be(99); }
public void CallStaticVoidMethodUsingFactory() { var rule = MethodCallRulesFactory.CreateStaticVoidMethodCallRule("SomeVoidStaticMethod", "ModelForUnitTests.Game", null); var compileResult = rule.Compile(); compileResult.Should().BeTrue(); _testOutputHelper.WriteLine($"rule: {Environment.NewLine}" + $"{rule.ExpressionDebugView()}"); Game.SomeStaticIntValue = 0; rule.Execute(); Game.SomeStaticIntValue.Should().Be(1); }