public void PrintFormattedString_When_FormatAndTwoArgumentAreSpecified() { // Arrange var fixture = new Fixture(); var expectedText1 = fixture.Create <string>(); var expectedText2 = fixture.Create <string>(); var originalConsoleOut = System.Console.Out; string formattedStringToBePrinted; using (var writer = new StringWriter()) { System.Console.SetOut(writer); // Act var consoleProvider = new ConsoleProvider(); consoleProvider.Write("{0}{1}", expectedText1, expectedText2); writer.Flush(); formattedStringToBePrinted = writer.GetStringBuilder().ToString(); } // Assert Assert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText1, expectedText2))); // Clean-up System.Console.SetOut(originalConsoleOut); }