Unit test
This commit is contained in:
28
ConsoleWriteUnitTest/UnitTest1.cs
Normal file
28
ConsoleWriteUnitTest/UnitTest1.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ConsoleWriteUnitTest {
|
||||
[TestClass]
|
||||
public class UnitTest1 {
|
||||
[TestMethod]
|
||||
public void TestConsoleWrite() {
|
||||
//Arrange
|
||||
string vartEredmeny = "Hello World!";
|
||||
|
||||
//Action
|
||||
using (var sw = new StringWriter()) {
|
||||
Console.SetOut(sw); //Atallitjuk az outputot
|
||||
|
||||
ConsoleWrite.Program.Main();
|
||||
|
||||
var kapottEredmeny = sw.ToString().Trim();
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(kapottEredmeny, vartEredmeny);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user