public void TesPrintingInt() { var number = 8; var result = Printers.PrintVariable(number); Assert.IsInstanceOfType(result, typeof(BinaryOutput)); Assert.AreEqual(result.ContentType, "text/plain"); Assert.AreEqual("8", result.Data); }
public void TesPrintingString() { string text = "Hello"; var result = Printers.PrintVariable(text); Assert.IsInstanceOfType(result, typeof(BinaryOutput)); Assert.AreEqual(result.ContentType, "text/plain"); Assert.AreEqual("\"Hello\"", result.Data); }
public void TestPrintingSimpleList() { List <int> numbers = new List <int>() { 1, 2, 3, 4, 5, 6 }; var result = Printers.PrintVariable(numbers); Assert.IsInstanceOfType(result, typeof(BinaryOutput)); Assert.AreEqual(result.ContentType, "text/plain"); Assert.AreEqual("List<int>(6) { 1, 2, 3, 4, 5, 6 }", result.Data); }
public void TestRemovalOfSubmission() { SimpleClass s = new SimpleClass() { TextField = "Simple" }; var result = Printers.PrintVariable(s); Assert.IsInstanceOfType(result, typeof(BinaryOutput)); Assert.AreEqual(result.ContentType, "text/plain"); Assert.AreEqual("PrinterTests.SimpleClass { TextField=\"Simple\" }", result.Data); }
public void TestAddingCustomPrinter() { Func <object, BinaryOutput> SimplePrinter = s => new BinaryOutput() { ContentType = "text/simpleclass", Data = s.ToString() }; Printers.RegisterCustomPrinter(typeof(SimpleClass), SimplePrinter); SimpleClass input = new SimpleClass() { TextField = "Simple" }; BinaryOutput result = Printers.PrintVariable(input); Assert.IsInstanceOfType(result, typeof(BinaryOutput)); Assert.AreEqual(result.ContentType, "text/simpleclass"); }