public void TestCopyMapToParameter() { var input = new RowsBuilder() .Row("in1", 1).Field("p1", "one").Field("p2", "two") .Row("in1", 2).Field("p1", "one").Field("p2", "two") .ToOperation(); var maps = new MapsBuilder() .Equals() .Item("1", null, "p1") .Item("2", null, "p2") .ToMaps(); var copyOperation = new CopyOperation("in1", "out"); var mapOperation = new MapOperation("out", "out", "string", maps); var output = TestOperation(input, copyOperation, mapOperation); Assert.AreEqual("one", output[0]["out"].ToString()); Assert.AreEqual("two", output[1]["out"].ToString()); }
public void MapEqualsWithParameter() { var input = new RowsBuilder() .Row("f1", "v1").Field("p1", 1).Field("p2", 2).Field("p3", 3) .Row("f1", "v2").Field("p1", 1).Field("p2", 2).Field("p3", 3) .Row("f1", "v3").Field("p1", 1).Field("p2", 2).Field("p3", 3) .ToOperation(); var maps = new MapsBuilder() .Equals().Item("v1", null, "p1").Item("v2", null, "p2").Item("*", null, "p3") .StartsWith() .EndsWith() .ToMaps(); var mapTransform = new MapOperation("f1", "o1", "int32", maps); var output = TestOperation(input, mapTransform); Assert.AreEqual(1, output[0]["o1"], "v1 maps to 1"); Assert.AreEqual(2, output[1]["o1"], "v2 maps to 2"); Assert.AreEqual(3, output[2]["o1"], "v3 maps to 3 (via catch-all)"); }
public void MapStartsWith() { var input = new RowsBuilder().Row("f1", "test1").Row("f1", "test2").Row("f1", "tes").ToOperation(); var maps = new MapsBuilder() .Equals().Item("*", "no") .StartsWith().Item("test", "yes") .EndsWith().ToMaps(); var map = new MapOperation("f1", "o1", "string", maps); var output = TestOperation(input, map); Assert.AreEqual("yes", output[0]["o1"], "test1 maps to yes"); Assert.AreEqual("yes", output[1]["o1"], "test2 maps to yes"); Assert.AreEqual("no", output[2]["o1"], "test maps to no (via catch-all)"); }
public void MapEndsWith() { var input = new RowsBuilder() .Row("f1", "1end") .Row("f1", "2end") .Row("f1", "start").ToOperation(); var maps = new MapsBuilder() .Equals().Item("*", "no") .StartsWith() .EndsWith().Item("end", "yes").ToMaps(); var mapTransform = new MapOperation("f1", "o1", "string", maps); var output = TestOperation(input, mapTransform); Assert.AreEqual("yes", output[0]["o1"]); Assert.AreEqual("yes", output[1]["o1"]); Assert.AreEqual("no", output[2]["o1"]); }
public void MapEquals() { var input = new RowsBuilder().Row("f1", "x").Row("f1", "a").Row("f1", "d").ToOperation(); var maps = new MapsBuilder() .Equals().Item("x", "y").Item("a", "b") .StartsWith() .EndsWith().ToMaps(); var map = new MapOperation("f1", "o1", "string", maps); var output = TestOperation(input, map); Assert.AreEqual("y", output[0]["o1"], "x maps to y"); Assert.AreEqual("b", output[1]["o1"], "a maps to b"); Assert.AreEqual("d", output[2]["o1"], "d stays d"); }