Esempio n. 1
0
        /// <summary>
        /// Runs a single JsonReaderTestCaseDescriptor test.
        /// </summary>
        /// <param name="testCase">The test case descriptor to run.</param>
        /// <param name="testConfiguration">The test configuration to use.</param>
        /// <param name="jsonValueComparer">The comparer to use to compare JSON OMs.</param>
        /// <param name="assert">The assertion handler.</param>
        public static void ReadAndVerifyJson(
            JsonReaderTestCaseDescriptor testCase,
            JsonReaderTestConfiguration testConfiguration,
            IJsonValueComparer jsonValueComparer,
            AssertionHandler assert,
            IExceptionVerifier exceptionVerifier)
        {
            TextReader testReader = new TestTextReader(new StringReader(testCase.JsonText))
            {
                FailOnPeek = true,
                FailOnSingleCharacterRead = true,
                ReadSizesEnumerator       = testConfiguration.ReadSizes.EndLessLoop()
            };

            JsonValue actualJsonResult = null;

            assert.ExpectedException(() =>
            {
                JsonReader jsonReader = testConfiguration.JsonReaderCreatorFunc(testReader, assert);
                actualJsonResult      = ReadJson(jsonReader, assert);
            },
                                     testCase.ExpectedException,
                                     exceptionVerifier);

            if (testCase.ExpectedException == null)
            {
                if (testCase.FragmentExtractor != null)
                {
                    actualJsonResult = testCase.FragmentExtractor(actualJsonResult);
                }

                jsonValueComparer = new JsonValueComparer();
                jsonValueComparer.Compare(testCase.ExpectedJson, actualJsonResult);
            }
        }
Esempio n. 2
0
 public void TestTextReaderReadToEnd()
 {
     using (var reader = new TestTextReader("abc\n\ndef\r\nghi")) {
         var contents = reader.ReadToEnd();
         Assert.AreEqual("abc\n\ndef\r\nghi", contents);
     }
 }
Esempio n. 3
0
        public void TestApplicationLifecycle()
        {
            //Set up application with mock console
            var reader      = new TestTextReader(new[] { "exit" });
            var console     = new TestConsole(new TestTextWriter(), reader);
            var application = new Application(console);

            application.Start(new string[] { });
        }
Esempio n. 4
0
		public void TestTextReaderReadLine() {
			using(var reader = new TestTextReader("abc\n\ndef\r\nghi")) {
				var line = reader.ReadLine();
				Assert.AreEqual("abc", line, "first line (\\n)");
				
				line = reader.ReadLine();
				Assert.AreEqual("", line, "second line (empty)");
				
				line = reader.ReadLine();
				Assert.AreEqual("def", line, "third line (\\r\\n)");
				
				line = reader.ReadLine();
				Assert.AreEqual("ghi", line, "fourth line (last)");
				
				line = reader.ReadLine();
				Assert.AreEqual(null, line, "eof");
			}
		}
Esempio n. 5
0
        public void TestTextReaderReadLine()
        {
            using (var reader = new TestTextReader("abc\n\ndef\r\nghi")) {
                var line = reader.ReadLine();
                Assert.AreEqual("abc", line, "first line (\\n)");

                line = reader.ReadLine();
                Assert.AreEqual("", line, "second line (empty)");

                line = reader.ReadLine();
                Assert.AreEqual("def", line, "third line (\\r\\n)");

                line = reader.ReadLine();
                Assert.AreEqual("ghi", line, "fourth line (last)");

                line = reader.ReadLine();
                Assert.AreEqual(null, line, "eof");
            }
        }
Esempio n. 6
0
 public TestOutputHandlerConsole(ITestOutputHelper helper, string readLine)
 {
     Out   = new TestOutputHelperTextWriter(helper, "STDOUT: ");
     Error = new TestOutputHelperTextWriter(helper, "STDERR: ");
     In    = new TestTextReader(readLine);
 }
Esempio n. 7
0
		public void TestTextReaderReadToEnd() {
			using(var reader = new TestTextReader("abc\n\ndef\r\nghi")) {
				var contents = reader.ReadToEnd();
				Assert.AreEqual("abc\n\ndef\r\nghi", contents);
			}
		}