~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/ExceptionTests.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#region License
 
2
// Copyright (c) 2007 James Newton-King
 
3
//
 
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
 
11
// conditions:
 
12
//
 
13
// The above copyright notice and this permission notice shall be
 
14
// included in all copies or substantial portions of the Software.
 
15
//
 
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.
 
24
#endregion
 
25
 
 
26
using System;
 
27
using Newtonsoft.Json.Schema;
 
28
#if !NETFX_CORE
 
29
using NUnit.Framework;
 
30
#else
 
31
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
 
32
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
 
33
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
 
34
#endif
 
35
 
 
36
namespace Newtonsoft.Json.Tests
 
37
{
 
38
  [TestFixture]
 
39
  public class ExceptionTests : TestFixtureBase
 
40
  {
 
41
    [Test]
 
42
    public void JsonSerializationException()
 
43
    {
 
44
      JsonSerializationException exception = new JsonSerializationException();
 
45
      Assert.AreEqual("Exception of type 'Newtonsoft.Json.JsonSerializationException' was thrown.", exception.Message);
 
46
 
 
47
      exception = new JsonSerializationException("Message!");
 
48
      Assert.AreEqual("Message!", exception.Message);
 
49
      Assert.AreEqual(null, exception.InnerException);
 
50
 
 
51
      exception = new JsonSerializationException("Message!", new Exception("Inner!"));
 
52
      Assert.AreEqual("Message!", exception.Message);
 
53
      Assert.AreEqual("Inner!", exception.InnerException.Message);
 
54
    }
 
55
 
 
56
    [Test]
 
57
    public void JsonWriterException()
 
58
    {
 
59
      JsonWriterException exception = new JsonWriterException();
 
60
      Assert.AreEqual("Exception of type 'Newtonsoft.Json.JsonWriterException' was thrown.", exception.Message);
 
61
 
 
62
      exception = new JsonWriterException("Message!");
 
63
      Assert.AreEqual("Message!", exception.Message);
 
64
      Assert.AreEqual(null, exception.InnerException);
 
65
 
 
66
      exception = new JsonWriterException("Message!", new Exception("Inner!"));
 
67
      Assert.AreEqual("Message!", exception.Message);
 
68
      Assert.AreEqual("Inner!", exception.InnerException.Message);
 
69
    }
 
70
 
 
71
    [Test]
 
72
    public void JsonReaderException()
 
73
    {
 
74
      JsonReaderException exception = new JsonReaderException();
 
75
      Assert.AreEqual("Exception of type 'Newtonsoft.Json.JsonReaderException' was thrown.", exception.Message);
 
76
 
 
77
      exception = new JsonReaderException("Message!");
 
78
      Assert.AreEqual("Message!", exception.Message);
 
79
      Assert.AreEqual(null, exception.InnerException);
 
80
 
 
81
      exception = new JsonReaderException("Message!", new Exception("Inner!"));
 
82
      Assert.AreEqual("Message!", exception.Message);
 
83
      Assert.AreEqual("Inner!", exception.InnerException.Message);
 
84
    }
 
85
 
 
86
    [Test]
 
87
    public void JsonSchemaException()
 
88
    {
 
89
      JsonSchemaException exception = new JsonSchemaException();
 
90
      Assert.AreEqual("Exception of type 'Newtonsoft.Json.Schema.JsonSchemaException' was thrown.", exception.Message);
 
91
 
 
92
      exception = new JsonSchemaException("Message!");
 
93
      Assert.AreEqual("Message!", exception.Message);
 
94
      Assert.AreEqual(null, exception.InnerException);
 
95
 
 
96
      exception = new JsonSchemaException("Message!", new Exception("Inner!"));
 
97
      Assert.AreEqual("Message!", exception.Message);
 
98
      Assert.AreEqual("Inner!", exception.InnerException.Message);
 
99
    }
 
100
  }
 
101
}
 
 
b'\\ No newline at end of file'