public static Operation FromTemplate(OperationTemplate template) { Operation op = null; if (template.op == "add") { op = new AddOperation(); } else if (template.op == "remove") { op = new RemoveOperation(); } else if (template.op == "test") { op = new TestOperation(); } else if (template.op == "move") { op = new MoveOperation(); } else if (template.op == "copy") { op = new CopyOperation(); } else if (template.op == "replace") { op = new ReplaceOperation(); } op.CopyPropertiesFrom(template); return op; }
public void ShouldResultInUnSuccessfullTest() { dynamic _Object = JObject.Parse(@" { 'baz': 'qux', 'foo': [ 'a', 2, 'c'], 'bar': {'littleBar': '123456789'} }" ); Operation operation = new TestOperation() { Target = _Object, Path = "$.baz", Value = "xuq" }; operation.Execute(); operation.IsInError.ShouldBe(true); operation = new TestOperation() { Target = _Object, Path = "$.foo[1]", Value = "2" }; operation.Execute(); operation.IsInError.ShouldBe(true); operation = new TestOperation() { Target = _Object, Path = "$.bar.littleBar", Value = 123456789 }; operation.Execute(); operation.IsInError.ShouldBe(true); }