public void ValidArguments_Run_ProducesLadderFile() { //setup var wordLadderRunner = new WordLadderRunner(fileIOMock.Object, grapgBuilderMock.Object, ladderBuilderMock.Object); var args = new string[] { "dictionary.txt", "spin", "spat", ladderFileName }; ladderBuilderMock.Setup <Dictionary <string, string> >(s => s.FindDistances(It.IsAny <string>(), It.IsAny <string>(), It.Is <Dictionary <string, List <string> > >(d => d == graph))).Returns(distanceTable); ladderBuilderMock.Setup <List <string> >(s => s.BuildPath(It.IsAny <string>(), It.IsAny <string>(), It.Is <Dictionary <string, string> >(d => d == distanceTable))).Returns(path); grapgBuilderMock.Setup <Dictionary <string, List <string> > >(s => s.BuildGraph(It.IsAny <List <string> >())) .Returns(graph); fileIOMock.Setup <List <string> >(s => s.ParseFile(It.IsAny <string>())).Returns(ShortWordList); fileIOMock.Setup <bool>(s => s.SaveLadder(It.Is <List <string> >(d => d == path), It.Is <string>(d => d == ladderFileName))) .Returns(true); using (var consoleoutput = new ConsoleOutput()) { //run wordLadderRunner.Run(args); //test consoleoutput.GetOuput().Contains($"Saved the word ladder to {ladderFileName}.").Should().BeTrue(); ((List <string>)fileIOMock.Invocations[1].Arguments[0]).Should().BeEquivalentTo(path); ((string)fileIOMock.Invocations[1].Arguments[1]).Should().Be(ladderFileName); } }
public void GivenThrreeArguments_Run_GivesUsageMessage() { //setup var wordLadderRunner = new WordLadderRunner(fileIOMock.Object, grapgBuilderMock.Object, ladderBuilderMock.Object); var args = new string[] { "cat", "dog", "dictionary.txt" }; using (var consoleoutput = new ConsoleOutput()) { //run wordLadderRunner.Run(args); //test consoleoutput.GetOuput().Contains("Only 3 arguments supplied on the command line.").Should().BeTrue(); consoleoutput.GetOuput().Contains("Please use: WordLadder DictionaryFile StartWord EndWord ResultFile").Should().BeTrue(); } }