Created
October 19, 2018 19:06
-
-
Save TomasDrozdik/2aa26f89dfe6ea0ea31848432104d622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Uloha4_ViceZarovnani; | |
namespace Uloha4ViceZarovnaniTests | |
{ | |
[TestClass] | |
public class ReaderUT | |
{ | |
[TestMethod] | |
public void ReadWord_EmptyInputTest() | |
{ | |
var input = new System.IO.StringReader(""); | |
Reader r = new Reader(input); | |
var output = new List<string>(); | |
var referenceOutput = new List<string>(); | |
while (!r.IsEof()) { | |
output.Add(r.ReadWord()); | |
} | |
Assert.AreEqual(output.ToString(), referenceOutput.ToString()); | |
} | |
[TestMethod] | |
public void ReadWord_SingleWordTest() | |
{ | |
var input = new System.IO.StringReader("hello"); | |
Reader r = new Reader(input); | |
var output = new List<string>(); | |
string[] refOut = { "hello" }; | |
var referenceOutput = new List<string>(refOut); | |
while (!r.IsEof()) { | |
output.Add(r.ReadWord()); | |
} | |
Assert.AreEqual(output.ToString(), referenceOutput.ToString()); | |
} | |
[TestMethod] | |
public void ReadWord_OneLineTest() | |
{ | |
var input = new System.IO.StringReader("Hello world test. How are you?"); | |
Reader r = new Reader(input); | |
var output = new List<string>(); | |
string[] refOut = { "Hello", "world", "test.", "How", "are", "you?" }; | |
var referenceOutput = new List<string>(refOut); | |
while (!r.IsEof()) { | |
output.Add(r.ReadWord()); | |
} | |
Assert.AreEqual(output.ToString(), referenceOutput.ToString()); | |
} | |
[TestMethod] | |
public void ReadWord_MultipleLineTest() | |
{ | |
var input = new System.IO.StringReader(" Hello world test.\n\n How are you\n? \n"); | |
Reader r = new Reader(input); | |
var output = new List<string>(); | |
string[] refOut = { "Hello", "world", "test.", "How", "are", "you?" }; | |
var referenceOutput = new List<string>(); | |
while (!r.IsEof()) { | |
output.Add(r.ReadWord()); | |
} | |
Assert.AreEqual(output.ToString(), referenceOutput.ToString()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Text; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using Uloha4_ViceZarovnani; | |
namespace Uloha4ViceZarovnaniTests | |
{ | |
[TestClass] | |
public class WriterUT | |
{ | |
[TestMethod] | |
public void WriteT() | |
{ | |
var sw = new StringWriter(new StringBuilder()); | |
var w = new Writer(sw); | |
var input = "Hello \nworld!"; | |
w.Write(input); | |
Assert.AreEqual(input, sw.ToString()); | |
} | |
[TestMethod] | |
public void WriteLineT() | |
{ | |
var sw = new StringWriter(new StringBuilder()); | |
var w = new Writer(sw); | |
var input = "Hello world!"; | |
w.WriteLine(input); | |
string referenceOutput = "Hello world!" + Environment.NewLine; | |
Assert.AreEqual(referenceOutput, sw.ToString()); | |
} | |
[TestMethod] | |
public void Write_HighlightT() | |
{ | |
var sw = new StringWriter(new StringBuilder()); | |
var w = new Writer(sw); | |
w.SetHighlightWhitespaces(true); | |
var input = "Hello \nworld!"; | |
w.Write(input); | |
string referenceOutput = "Hello.<-\nworld!"; | |
Assert.AreEqual(referenceOutput, sw.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment