示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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");
        }