using System.Linq; using HeuristicLab.Problems.ProgramSynthesis; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace HeuristicLab.Tests.Components { [TestClass] public class PrintStackTests { private PrintStack printStack; [TestInitialize] public void BeforeTest() { printStack = new PrintStack(); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ComponentTest")] public void TestPushLong() { printStack.Push(100L); Assert.AreEqual(100L.ToString(), printStack.ToString()); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ComponentTest")] public void TestPushDouble() { printStack.Push(100.5D); Assert.AreEqual(100.5D.ToString(), printStack.ToString()); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ComponentTest")] public void TestAsStringsWithNewline() { printStack.Push(100.5D); printStack.Push(10); printStack.NewLine(); printStack.Push("abc"); printStack.Push('d'); var lines = printStack.AsStrings().ToList(); Assert.AreEqual(2, lines.Count); Assert.AreEqual("100,510", lines[0]); Assert.AreEqual("abcd", lines[1]); } [TestMethod] [TestProperty("Time", "Short")] [TestCategory("ComponentTest")] public void TestAsStringsWithoutNewline() { printStack.Push(100.5D); printStack.Push(10); var lines = printStack.AsStrings().ToList(); Assert.AreEqual(1, lines.Count); Assert.AreEqual("100,510", lines[0]); } } }