コード例 #1
0
		public string ExecuteAddTest(string command)
		{
			var textReader = Substitute.For<TextReader>();
			Console.SetIn(textReader);
			var textWriter = Substitute.For<TextWriter>();
			Console.SetOut(textWriter);

			textReader.ReadLine().Returns(command);

			string result = null;
			textWriter
				.When(w => w.WriteLine(Arg.Any<string>()))
				.Do(c => result = c.Arg<string>());

			var stringCalculator = new StringCalculator();
			stringCalculator.ExecuteAdd(Console.ReadLine());

			return result;
		}