public void TestMergeInstructions() { var route = new Route() { Shape = new Coordinate[] { new Coordinate(0, 0), new Coordinate(0, 0), new Coordinate(0, 0) }, ShapeMeta = new Route.Meta[] { new Route.Meta() { Shape = 0 }, new Route.Meta() { Shape = 1 }, new Route.Meta() { Shape = 2 } }, TotalDistance = 0, TotalTime = 0 }; var generator = new InstructionGenerator <string>(route, new InstructionGenerator <string> .TryGetDelegate[] { (RoutePosition pos, ILanguageReference langRef, out string instruction) => { instruction = string.Format("Instruction {0}", pos.Shape); return(1); } }, (Route r, ILanguageReference langRef, string i1, string i2, out string i) => { i = string.Format("Merged instruction: {0} -> {1}", i1, i2); return(true); }, new MockLanguageReference()); generator.Run(); var instructions = generator.Instructions; Assert.IsNotNull(instructions); Assert.AreEqual(1, instructions.Count); Assert.AreEqual("Merged instruction: Merged instruction: Instruction 0 -> Instruction 1 -> Instruction 2", instructions[0]); }
public void TestOverwritingInstructions() { var route = new Route() { Shape = new Coordinate[] { new Coordinate(0, 0), new Coordinate(0, 0), new Coordinate(0, 0) }, ShapeMeta = new Route.Meta[] { new Route.Meta() { Shape = 0 }, new Route.Meta() { Shape = 1 }, new Route.Meta() { Shape = 2 } }, TotalDistance = 0, TotalTime = 0 }; var generator = new InstructionGenerator <string>(route, new InstructionGenerator <string> .TryGetDelegate[] { (RoutePosition pos, ILanguageReference langRef, out string instruction) => { if (pos.Shape == 2) { instruction = "The one and only instruction!"; return(3); } instruction = string.Format("Instruction {0}", pos.Shape); return(1); } }, new MockLanguageReference()); generator.Run(); var instructions = generator.Instructions; Assert.IsNotNull(instructions); Assert.AreEqual(1, instructions.Count); Assert.AreEqual("The one and only instruction!", instructions[0]); }