2
// Copyright (c) 2007 James Newton-King
4
// Permission is hereby granted, free of charge, to any person
5
// obtaining a copy of this software and associated documentation
6
// files (the "Software"), to deal in the Software without
7
// restriction, including without limitation the rights to use,
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the
10
// Software is furnished to do so, subject to the following
13
// The above copyright notice and this permission notice shall be
14
// included in all copies or substantial portions of the Software.
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
// OTHER DEALINGS IN THE SOFTWARE.
27
using Newtonsoft.Json.Schema;
29
using NUnit.Framework;
31
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
32
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
33
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
36
namespace Newtonsoft.Json.Tests
39
public class ExceptionTests : TestFixtureBase
42
public void JsonSerializationException()
44
JsonSerializationException exception = new JsonSerializationException();
45
Assert.AreEqual("Exception of type 'Newtonsoft.Json.JsonSerializationException' was thrown.", exception.Message);
47
exception = new JsonSerializationException("Message!");
48
Assert.AreEqual("Message!", exception.Message);
49
Assert.AreEqual(null, exception.InnerException);
51
exception = new JsonSerializationException("Message!", new Exception("Inner!"));
52
Assert.AreEqual("Message!", exception.Message);
53
Assert.AreEqual("Inner!", exception.InnerException.Message);
57
public void JsonWriterException()
59
JsonWriterException exception = new JsonWriterException();
60
Assert.AreEqual("Exception of type 'Newtonsoft.Json.JsonWriterException' was thrown.", exception.Message);
62
exception = new JsonWriterException("Message!");
63
Assert.AreEqual("Message!", exception.Message);
64
Assert.AreEqual(null, exception.InnerException);
66
exception = new JsonWriterException("Message!", new Exception("Inner!"));
67
Assert.AreEqual("Message!", exception.Message);
68
Assert.AreEqual("Inner!", exception.InnerException.Message);
72
public void JsonReaderException()
74
JsonReaderException exception = new JsonReaderException();
75
Assert.AreEqual("Exception of type 'Newtonsoft.Json.JsonReaderException' was thrown.", exception.Message);
77
exception = new JsonReaderException("Message!");
78
Assert.AreEqual("Message!", exception.Message);
79
Assert.AreEqual(null, exception.InnerException);
81
exception = new JsonReaderException("Message!", new Exception("Inner!"));
82
Assert.AreEqual("Message!", exception.Message);
83
Assert.AreEqual("Inner!", exception.InnerException.Message);
87
public void JsonSchemaException()
89
JsonSchemaException exception = new JsonSchemaException();
90
Assert.AreEqual("Exception of type 'Newtonsoft.Json.Schema.JsonSchemaException' was thrown.", exception.Message);
92
exception = new JsonSchemaException("Message!");
93
Assert.AreEqual("Message!", exception.Message);
94
Assert.AreEqual(null, exception.InnerException);
96
exception = new JsonSchemaException("Message!", new Exception("Inner!"));
97
Assert.AreEqual("Message!", exception.Message);
98
Assert.AreEqual("Inner!", exception.InnerException.Message);
b'\\ No newline at end of file'