public void should_give_verses_when_asked_for_poetry_with_the_support_of_a_poetry_library() { IObtainPoems poetryLibrary = Substitute.For <IObtainPoems>(); poetryLibrary.GetMeAPoem().Returns("If you could read a leaf or tree\r\nyou'd have no need of books.\r\n-- Alistair Cockburn (1987)"); var poetryReader = new PoetryReader(poetryLibrary); var verse = poetryReader.GiveMeSomePoetry(); Check.That(verse).IsEqualTo("If you could read a leaf or tree\r\nyou'd have no need of books.\r\n-- Alistair Cockburn (1987)"); }
public void should_provide_verses_when_asked_for_poetry_with_the_support_of_a_console_adapter() { // 1. Instantiate the right-side adapter(s) ("I want to go outside the hexagon") IObtainPoems poetryLibrary = Substitute.For <IObtainPoems>(); poetryLibrary.GetMeAPoem().Returns("If you could read a leaf or tree\r\nyou'd have no need of books.\r\n-- Alistair Cockburn (1987)"); // 2. Instantiate the hexagon var poetryReader = new PoetryReader(poetryLibrary); IWriteLines publicationStrategy = Substitute.For <IWriteLines>(); // 3. Instantiate the left-side adapter(s) ("I need to enter the hexagon") var consoleAdapter = new ConsoleAdapter(poetryReader, publicationStrategy); consoleAdapter.Ask(); // Check that Console.WriteLine has been called with infra specific details "Poem:\r\n" added publicationStrategy.Received().WriteLine("Poem:\r\nIf you could read a leaf or tree\r\nyou'd have no need of books.\r\n-- Alistair Cockburn (1987)"); }