コード例 #1
0
ファイル: JsonReaderUtils.cs プロジェクト: zhonli/odata.net
        /// <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);
            }
        }
コード例 #2
0
ファイル: TextReaderTest.cs プロジェクト: pmq20/mono_forked
 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);
     }
 }
コード例 #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[] { });
        }
コード例 #4
0
ファイル: TextReaderTest.cs プロジェクト: nlhepler/mono
		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");
			}
		}
コード例 #5
0
ファイル: TextReaderTest.cs プロジェクト: pmq20/mono_forked
        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");
            }
        }
コード例 #6
0
 public TestOutputHandlerConsole(ITestOutputHelper helper, string readLine)
 {
     Out   = new TestOutputHelperTextWriter(helper, "STDOUT: ");
     Error = new TestOutputHelperTextWriter(helper, "STDERR: ");
     In    = new TestTextReader(readLine);
 }
コード例 #7
0
ファイル: TextReaderTest.cs プロジェクト: nlhepler/mono
		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);
			}
		}