class Kata{ public static void Main(){ string greeting = "Hello"; string language = "C#"; System.Console.WriteLine("{0}, {1}!", greeting, language); } }
- class Kata{
- public static void Main(){
- string greeting = "Hello";
- string language = "C#";
System.Console.WriteLine("Hello, {0}!",language);- System.Console.WriteLine("{0}, {1}!", greeting, language);
- }
- }
using NUnit.Framework; using System; using System.IO; [TestFixture] public class KataTests { [Test] public void Prints_expected_output() { var originalConsoleOut = Console.Out; // preserve the original stream var writer = new StringWriter(); Console.SetOut(writer); //ready to listen to console Kata.Main(); writer.Flush(); // when you're done, make sure everything is written out var myString = writer.GetStringBuilder().ToString(); Console.SetOut(originalConsoleOut); // restore Console output Assert.AreEqual("Hello, C#!\n" , myString); } }
- using NUnit.Framework;
- using System;
- using System.IO;
- [TestFixture]
public class StringToNumberTest- public class KataTests
- {
- [Test]
public void test1()- public void Prints_expected_output()
- {
- var originalConsoleOut = Console.Out; // preserve the original stream
- var writer = new StringWriter();
- Console.SetOut(writer);
- //ready to listen to console
- Kata.Main();
- writer.Flush(); // when you're done, make sure everything is written out
- var myString = writer.GetStringBuilder().ToString();
- Console.SetOut(originalConsoleOut); // restore Console output
- Assert.AreEqual("Hello, C#!\n" , myString);
- }
- }