using System; class Kata { public static void Main() { string greeting = "Hello"; string language = "JS"; Console.WriteLine($"{greeting}, {language}!"); } }
- using System;
- class Kata
- {
- public static void Main()
- {
- string greeting = "Hello";
string language = "C#";- string language = "JS";
- Console.WriteLine($"{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, JS!\n" , myString); } }
- 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#!" , myString);- Assert.AreEqual("Hello, JS!
- " , myString);
- }
- }