Repository: facebook-csharp-sdk/simple-json Branch: master Commit: f739f0b2924b Files: 112 Total size: 1.8 MB Directory structure: gitextract_9s43uv8o/ ├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── VERSION ├── jakefile.js └── src/ ├── JsonViewer/ │ ├── JsonViewer.Designer.cs │ ├── JsonViewer.cs │ ├── JsonViewer.csproj │ ├── JsonViewer.resx │ ├── Program.cs │ └── Properties/ │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── SimpleJson/ │ ├── EscapeToJavascriptStringTests.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── SimpleJson-Net20.csproj │ ├── SimpleJson-Net35.csproj │ ├── SimpleJson-Net40.csproj │ ├── SimpleJson-Net45.csproj │ ├── SimpleJson-Portable-NoLinqExpression.csproj │ ├── SimpleJson-Portable-WP8WinStoreNet45.csproj │ ├── SimpleJson-Portable.csproj │ ├── SimpleJson-SL4.csproj │ ├── SimpleJson-SL5.csproj │ ├── SimpleJson-WP7.csproj │ ├── SimpleJson-WP71.csproj │ ├── SimpleJson-WindowsStore.csproj │ └── SimpleJson.cs ├── SimpleJson.Tests/ │ ├── DataContractTests/ │ │ ├── DataContractSampleClassess.cs │ │ ├── PrivateFieldsSerializeTests.cs │ │ ├── PrivateGetterSettersSerializeTests.cs │ │ ├── PrivateGettersSerializeTests.cs │ │ ├── PrivateReadonlySerializeTests.cs │ │ ├── PrivateSettersSerializeTests.cs │ │ ├── PublicFieldsSerializeTests.cs │ │ ├── PublicGetterSetterDeserializeTests.cs │ │ ├── PublicGetterSettersSerializeTests.cs │ │ ├── PublicGettersSerializeTests.cs │ │ ├── PublicReadonlySerializeTests.cs │ │ └── PublicSettersSerializeTests.cs │ ├── DeserializeGenericListTests.cs │ ├── DeserializeObjectTests.cs │ ├── EscapeToJavascriptStringTests.cs │ ├── JsonArrayTests.cs │ ├── JsonDataContractSerializeObjectTests.cs │ ├── JsonDecodeTypeTests.cs │ ├── Package.appxmanifest │ ├── PocoDeserializerTests/ │ │ ├── ArrayTests.cs │ │ ├── DateTimeDeserializeTests.cs │ │ ├── DictionaryDeserializeTests.cs │ │ ├── ListOfPocoDeserializeTests.cs │ │ ├── NullableTypeDeserializeTests.cs │ │ └── PrimitiveDeserializeTest.cs │ ├── PocoJsonSerializerTests/ │ │ ├── DateTimeSerializeTests.cs │ │ ├── NullableSerializeTests.cs │ │ ├── PrivateFieldsDeserializeTests.cs │ │ ├── PrivateFieldsSerializeTests.cs │ │ ├── PrivateGetterSettersDeserializeTests.cs │ │ ├── PrivateGetterSettersSerializeTests.cs │ │ ├── PrivateGettersSerializeTests.cs │ │ ├── PrivateReadonlySerializeTests.cs │ │ ├── PrivateSettersSerializeTests.cs │ │ ├── PublicFieldsDeserializeTests.cs │ │ ├── PublicFieldsSerializeTests.cs │ │ ├── PublicGetterDeserializeTests.cs │ │ ├── PublicGetterSetterDeserializeTests.cs │ │ ├── PublicGetterSettersSerializeTests.cs │ │ ├── PublicGettersSerializeTests.cs │ │ ├── PublicReadonlySerializeTests.cs │ │ ├── PublicSettersSerializeTests.cs │ │ └── ToStringTests.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── SerializeObject.KnownNonPrimitive.Tests.cs │ ├── SerializeObject.Primitive.Tests.cs │ ├── SerializeObject.UnknownNonPrimitive.Tests.cs │ ├── SimleJson.Tests-WindowsStore.csproj │ ├── SimleJson.Tests-WindowsStore_TemporaryKey.pfx │ ├── SimpleJson.Tests.csproj │ └── packages.config ├── SimpleJson.nuspec ├── SimpleJson.sln ├── njake.js ├── packages/ │ ├── NUnit.2.5.10.11092/ │ │ ├── NUnit.2.5.10.11092.nupkg │ │ ├── NUnitFitTests.html │ │ ├── fit-license.txt │ │ ├── lib/ │ │ │ └── nunit.framework.xml │ │ ├── license.txt │ │ └── tools/ │ │ ├── NUnitTests.VisualState.xml │ │ ├── NUnitTests.config │ │ ├── NUnitTests.nunit │ │ ├── TestResult.xml │ │ ├── agent.conf │ │ ├── agent.log.conf │ │ ├── launcher.log.conf │ │ ├── nunit-agent-x86.exe.config │ │ ├── nunit-agent.exe.config │ │ ├── nunit-console-x86.exe.config │ │ ├── nunit-console.exe.config │ │ ├── nunit-x86.exe.config │ │ ├── nunit.exe.config │ │ ├── pnunit-agent.exe.config │ │ ├── pnunit-launcher.exe.config │ │ ├── runFile.exe.config │ │ ├── runpnunit.bat │ │ └── test.conf │ ├── NuGet.CommandLine.1.7.0/ │ │ └── NuGet.CommandLine.1.7.0.nupkg │ └── repositories.config └── simplejson.script.ps1 ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain *.jpg binary *.png binary *.gif binary *.cs -text diff=csharp *.vb -text *.c -text *.cpp -text *.cxx -text *.h -text *.hxx -text *.py -text *.rb -text *.java -text *.html -text *.htm -text *.css -text *.scss -text *.sass -text *.less -text *.js -text *.lisp -text *.clj -text *.sql -text *.php -text *.lua -text *.m -text *.asm -text *.erl -text *.fs -text *.fsx -text *.hs -text *.csproj -text merge=union *.vbproj -text merge=union *.fsproj -text merge=union *.dbproj -text merge=union *.sln -text eol=crlf merge=union ================================================ FILE: .gitignore ================================================ # Visual Studio Ignores [Bb]in/ obj/ App_Data/ *.sln.cache *.suo *.user *.build.csdef *.ncb *.docstates # Visual Studio 11+ Unit Test ignores *.UTests.ldf *.UTests.mdf *.xap !*StatLight.Client.For.*.xap *.userprefs # Mono develop # Visual Studio Extensions Ignores .vs10x *.vs10x # Resharper Ignores _ReSharper.*/ *.resharper.user # StyleCop cache ignores *StyleCop.Cache # Ignore TypeMock TestLint Cache lint.db # vim Ignore *.swp # kdiff3 Ignore *.orig # LATEX Ignores *.tex.undo # Misc Ignores Thumbs.db !libs/*/[Bb]in/ working/ src/TestResults/ dist/ ================================================ FILE: LICENSE.txt ================================================ Copyright (c) 2011, The Outercurve Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: NOTICE.txt ================================================ Copyright (c) 2011, The Outercurve Foundation. This software is released under the MIT License (the "License"); you may not use the software except in compliance with the License. You can find a copy of the License in the file LICENSE.TXT accompanying this file. Additional Copyrights: This library was derived from code created by Procuriouis (procurios.nl), Copyright (c) 2008, Procurios. Additional Libraries: This software includes or is derivative of works distributed under the licenses listed below. The full text for most of the licenses listed below can be found in the LICENSE.txt file accompanying each work. The original copyright notices have been preserved within the respective files and or packages. Please refer to the specific files and/or packages for more detailed information about the authors, copyright notices, and licenses. njake ----------------- Website: https://github.com/prabirshrestha/njake Copyright: N/A License: Apache 2.0 License JSON.cs ----------------- Website: http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html Copyright: Copyright (c) 2008, Procurios License: MIT License Additional Notices: The software was originally conceived and created by Nathan Totten, Prabir Shersha, and Jim Zimmerman. Other contributors to the project include: N/A ================================================ FILE: README.md ================================================ # SimpleJson Small and fast JSON library for .NET 2.0+/SL4+/WP7+/Windows Store Apps/Portable Class Library and powershell. Includes support for dynamic in .NET 4.0+/SL4+/Windows Store Apps. Also includes support for DataContract and DataMember. # Using SimpleJson SimpleJson is not distributed as a compiled binary .dll file but rather as a single .cs file or a powershell module .psm1. **Use nuget to add SimpleJson.cs file to your project.** ```powershell Install-Package SimpleJson ``` ## Supported Platforms * .NET 2.0 * .NET 3.0 * .NET 3.5 (Client Profile and Full Profile) * .NET 4.0 (Client Profile and Full Profile) * .NET 4.5 * Windows 8 Store Apps * Silverlight 4 * Silverlight 5 * Windows Phone 7.0 * Windows Phone 7.1 (Mango) * Windows Phone 8 * Portable Class Libraries (PCL) **Note:** By default SimpleJson expects `System.Linq`. If you are targeting older version of .NET framework (.net < 3.0 or WP7.0) you will need to add `#define SIMPLE_JSON_NO_LINQ_EXPRESSION`. If you want to use `[DataContract]`, `[DataMember(Name = "name")]` or `[IgnoreDataMember]` make sure to add `#define SIMPLE_JSON_DATACONTRACT`. If you want to use `IReadOnlyCollection` and `IReadOnlyList` make sure to add `#define SIMPLE_JSON_READONLY_COLLECTIONS`. ================================================ FILE: VERSION ================================================ 0.38.0 ================================================ FILE: jakefile.js ================================================ var fs = require('fs'), njake = require('./src/njake'), msbuild = njake.msbuild, nunit = njake.nunit, nuget = njake.nuget, config = { version: fs.readFileSync('VERSION', 'utf-8') }; console.log('SimpleJson v' + config.version) msbuild.setDefaults({ properties: { Configuration: 'Release' }, processor: 'x86', version: 'net4.0' }) nunit.setDefaults({ _exe: 'src/packages/NUnit.2.5.10.11092/tools/nunit-console-x86.exe' }) nuget.setDefaults({ _exe: 'src/packages/NuGet.CommandLine.1.7.0/tools/NuGet.exe', verbose: true }) desc('Build all') task('default', ['clean', 'build', 'test', 'nuget:pack']) namespace('build', function () { desc('Build Portble Class Library (with LINQ Expression)') task('pcl', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Portable.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Portble Class Library (without LINQ Expression)') task('pclnolinq', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Portable-NoLinqExpression.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Portble Class Library (WP8,WinStore,NET4.5)') task('pclnet45', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Portable-WP8WinStoreNet45.csproj', targets: ['Build'] }) }, { async: true }) desc('Build .NET 4.5') task('net45', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net45.csproj', targets: ['Build'] }) }, { async: true }) desc('Build .NET 4.0') task('net40', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net40.csproj', targets: ['Build'] }) }, { async: true }) desc('Build .NET 3.5') task('net35', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net35.csproj', targets: ['Build'] }) }, { async: true }) desc('Build .NET 2.0') task('net20', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net20.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Silverlight 5') task('sl5', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-SL5.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Silverlight 4') task('sl4', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-SL4.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Windows Phone 7.0') task('wp70', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-WP7.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Windows Phone 7.1') task('wp71', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-WP71.csproj', targets: ['Build'] }) }, { async: true }) desc('Build Windows Store') task('store', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-WindowsStore.csproj', targets: ['Build'] }) }, { async: true }) task('all', ['build:net40', 'build:net35', 'build:net20', 'build:sl5', 'build:sl4', 'build:wp70', 'build:wp71', 'build:net45', 'build:store', 'build:pcl', 'build:pclnolinq', 'build:pclnet45']) }) task('build', ['build:all']) namespace('clean', function () { task('pcl', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Portable.csproj', targets: ['Clean'] }) }, { async: true }) task('pclnolinq', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Portable-NoLinqExpression.csproj', targets: ['Clean'] }) }, { async: true }) task('pclnet45', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Portable-WP8WinStoreNet45.csproj', targets: ['Clean'] }) }, { async: true }) task('net45', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net45.csproj', targets: ['Clean'] }) }, { async: true }) task('net40', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net40.csproj', targets: ['Clean'] }) }, { async: true }) task('net35', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net35.csproj', targets: ['Clean'] }) }, { async: true }) task('net20', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-Net20.csproj', targets: ['Clean'] }) }, { async: true }) task('sl5', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-SL5.csproj', targets: ['Clean'] }) }, { async: true }) task('sl4', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-SL4.csproj', targets: ['Clean'] }) }, { async: true }) task('wp70', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-WP7.csproj', targets: ['Clean'] }) }, { async: true }) task('wp71', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-WP71.csproj', targets: ['Clean'] }) }, { async: true }) task('store', function () { msbuild({ file: 'src/SimpleJson/SimpleJson-WindowsStore.csproj', targets: ['Clean'] }) }, { async: true }) task('all', ['clean:net40', 'clean:net35', 'clean:net20', 'clean:sl5', 'clean:sl4', 'clean:wp70', 'clean:wp71', 'clean:net45', 'clean:store', 'clean:pcl', 'clean:pclnolinq', 'clean:pclnet45']) }) desc('Clean') task('clean', ['clean:all'], function () { jake.rmRf('working/') jake.rmRf('bin/') jake.rmRf('dist/') }) namespace('test-build', function () { task('net40', ['build:net40'], function () { msbuild({ file: 'src/SimpleJson.Tests/SimpleJson.Tests.csproj', targets: ['Build'] }) }, { async: true }) task('all', ['test-build:net40']) }) namespace('test', function () { task('net40', ['test-build:net40'], function () { nunit({ assemblies: ['bin/Tests/Net40/Release/SimpleJson.Tests.dll'], xml: 'bin/Tests/Net40/Release/SimpleJson.Tests.nunit.xml' }) }, { async: true }) task('all', ['test:net40']) }) desc('test') task('test', ['test:all']) directory('working/') namespace('generate', function () { desc('Generate SimpleJson.cs.pp at working/SimpleJson.cs.pp') task('csharp', ['working/'], function () { console.log('Generating working/SimpleJson.cs'); var csFile = fs .readFileSync('src/SimpleJson/SimpleJson.cs', 'utf-8') .replace('// VERSION:', '// VERSION: ' + config.version) .replace('namespace SimpleJson', 'namespace $rootnamespace$') .replace('namespace SimpleJson', 'namespace $rootnamespace$') .replace('using SimpleJson.Reflection;', 'using $rootnamespace$.Reflection;') fs.writeFileSync('working/SimpleJson.cs.pp', csFile); }) desc('Generate SimpleJson.psm1 at working/SimpleJson.psm1') task('powershell', ['working/'], function () { console.log('Generating working/SimpleJson.psm1'); var psFile = fs .readFileSync('src/simplejson.script.ps1', 'utf-8') .replace('# Version:', '# Version: ' + config.version) + '\r\n$source = @\"\r\n\r\n' + '#define SIMPLE_JSON_DATACONTRACT\r\n' + '#define SIMPLE_JSON_REFLECTIONEMIT\r\n\r\n' + fs.readFileSync('src/SimpleJson/SimpleJson.cs', 'utf-8').replace('// VERSION:', '// VERSION: ' + config.version) + '\r\n\"@\r\n' + 'Export-ModuleMember ConvertFrom-Json\r\n' + 'Export-ModuleMember ConvertTo-Json\r\n' + 'Add-Type -ReferencedAssemblies System.Runtime.Serialization -TypeDefinition $source -Language CSharp'; fs.writeFileSync('working/SimpleJson.psm1', psFile); }) task('all', ['generate:csharp', 'generate:powershell']) }) directory('dist/') namespace('nuget', function () { desc('Create nuget package') task('pack', ['generate:all', 'dist/'], function () { nuget.pack({ nuspec: 'src/SimpleJson.nuspec', version: config.version, outputDirectory: 'dist/' }) }, { async: true }) }) ================================================ FILE: src/JsonViewer/JsonViewer.Designer.cs ================================================ namespace JsonViewer { partial class JsonViewer { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(JsonViewer)); this.txtInput = new System.Windows.Forms.TextBox(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.mnuClear = new System.Windows.Forms.ToolStripButton(); this.tvJson = new System.Windows.Forms.TreeView(); this.txtJson = new System.Windows.Forms.TextBox(); this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // txtInput // this.txtInput.Location = new System.Drawing.Point(12, 28); this.txtInput.Multiline = true; this.txtInput.Name = "txtInput"; this.txtInput.Size = new System.Drawing.Size(774, 141); this.txtInput.TabIndex = 0; this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged); // // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton2, this.toolStripButton3, this.toolStripSeparator1, this.mnuClear}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(798, 25); this.toolStrip1.TabIndex = 1; this.toolStrip1.Text = "toolStrip1"; // // toolStripButton2 // this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(39, 22); this.toolStripButton2.Text = "Copy"; // // toolStripButton3 // this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(39, 22); this.toolStripButton3.Text = "Paste"; // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); // // mnuClear // this.mnuClear.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.mnuClear.Image = ((System.Drawing.Image)(resources.GetObject("mnuClear.Image"))); this.mnuClear.ImageTransparentColor = System.Drawing.Color.Magenta; this.mnuClear.Name = "mnuClear"; this.mnuClear.Size = new System.Drawing.Size(38, 22); this.mnuClear.Text = "Clear"; this.mnuClear.Click += new System.EventHandler(this.mnuClear_Click); // // tvJson // this.tvJson.Location = new System.Drawing.Point(12, 175); this.tvJson.Name = "tvJson"; this.tvJson.Size = new System.Drawing.Size(521, 339); this.tvJson.TabIndex = 2; // // txtJson // this.txtJson.Location = new System.Drawing.Point(539, 175); this.txtJson.Multiline = true; this.txtJson.Name = "txtJson"; this.txtJson.ReadOnly = true; this.txtJson.Size = new System.Drawing.Size(247, 339); this.txtJson.TabIndex = 3; this.txtJson.TextChanged += new System.EventHandler(this.txtJson_TextChanged); // // JsonViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(798, 526); this.Controls.Add(this.txtJson); this.Controls.Add(this.tvJson); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.txtInput); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.Name = "JsonViewer"; this.Text = "JsonViewer - powered by Simple Json (http://simplejson.codeplex.com)"; this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.TextBox txtInput; private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStripButton toolStripButton2; private System.Windows.Forms.ToolStripButton toolStripButton3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripButton mnuClear; private System.Windows.Forms.TreeView tvJson; private System.Windows.Forms.TextBox txtJson; } } ================================================ FILE: src/JsonViewer/JsonViewer.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace JsonViewer { public partial class JsonViewer : Form { private Color defaultColor; public JsonViewer() { InitializeComponent(); defaultColor = txtJson.BackColor; } private void mnuClear_Click(object sender, EventArgs e) { txtInput.Text = string.Empty; } private void txtInput_TextChanged(object sender, EventArgs e) { txtJson.Text = txtInput.Text; } private void txtJson_TextChanged(object sender, EventArgs e) { object obj; tvJson.Nodes.Clear(); if (SimpleJson.SimpleJson.TryDeserializeObject(txtJson.Text, out obj)) { var rootNode = new TreeNode("JSON"); tvJson.Nodes.Add(rootNode); AddNode(obj, rootNode); txtJson.BackColor = this.defaultColor; } else if (txtJson.Text.Trim().Length != 0) { txtJson.BackColor = Color.IndianRed; } } #region Node Helpers private void AddNode(object obj, TreeNode node) { if (obj is IList) { AddNode((IList)obj, node); } else if (obj is IDictionary) { AddNode((IDictionary)obj, node); } else { if (obj == null) { node.Nodes.Add("null"); } else { node.Nodes.Add(obj.ToString()); } node.ExpandAll(); } } private void AddNode(IDictionary dictionary, TreeNode node) { if (dictionary.Count == 0) { node.Nodes.Add("{}"); } else { foreach (var pair in dictionary) { var key = pair.Key; if (pair.Value is IDictionary) { var n = new TreeNode(pair.Key); node.Nodes.Add(n); AddNode(pair.Value, n); } else if (pair.Value is IList) { var n = new TreeNode("[] " + pair.Key); node.Nodes.Add(n); AddNode((IList)pair.Value, n); } else { // todo: differentiate null node.Nodes.Add(string.Format("{0} : {1}", pair.Key, pair.Value)); } node.ExpandAll(); } } } private void AddNode(IList list, TreeNode node) { foreach (var o in list) { AddNode(o, node); } } #endregion } } ================================================ FILE: src/JsonViewer/JsonViewer.csproj ================================================  Debug x86 8.0.30703 2.0 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639} WinExe Properties JsonViewer JsonViewer v4.0 Client 512 x86 true full false ..\..\bin\JsonViewer\Debug\ TRACE;DEBUG;SIMPLE_JSON_DYNAMIC prompt 4 x86 pdbonly true ..\..\bin\JsonViewer\Release\ TRACE prompt 4 SimpleJson.cs Form JsonViewer.cs JsonViewer.cs ResXFileCodeGenerator Resources.Designer.cs Designer True Resources.resx SettingsSingleFileGenerator Settings.Designer.cs True Settings.settings True ================================================ FILE: src/JsonViewer/JsonViewer.resx ================================================  text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 17, 17 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC 25 ================================================ FILE: src/JsonViewer/Program.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace JsonViewer { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new JsonViewer()); } } } ================================================ FILE: src/JsonViewer/Properties/AssemblyInfo.cs ================================================ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("JsonViewer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("The Outercurve Foundation")] [assembly: AssemblyProduct("JsonViewer")] [assembly: AssemblyCopyright("Copyright © The Outercurve Foundation 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("49995661-8835-4e5a-9863-95ebf1f74cd2")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] ================================================ FILE: src/JsonViewer/Properties/Resources.Designer.cs ================================================ //------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace JsonViewer.Properties { /// /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if ((resourceMan == null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JsonViewer.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } } ================================================ FILE: src/JsonViewer/Properties/Resources.resx ================================================  text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ================================================ FILE: src/JsonViewer/Properties/Settings.Designer.cs ================================================ //------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace JsonViewer.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } } } ================================================ FILE: src/JsonViewer/Properties/Settings.settings ================================================  ================================================ FILE: src/SimpleJson/EscapeToJavascriptStringTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class EscapeToJavascriptStringTests { [TestMethod] public void BackSlash() { var serialized = SimpleJson.SerializeObject("c:\\haha.pl"); var result = SimpleJson.EscapeToJavascriptString(serialized); Assert.AreEqual("\"c:\\haha.pl\"", result); } [TestMethod] public void BackSlashWithT() { var serialized = SimpleJson.SerializeObject("c:\\taha.pl"); var result = SimpleJson.EscapeToJavascriptString(serialized); Assert.AreEqual("\"c:\\taha.pl\"", result); } } } ================================================ FILE: src/SimpleJson/Properties/AssemblyInfo.cs ================================================ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("SimpleJson")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("The Outercurve Foundation")] [assembly: AssemblyProduct("SimpleJson")] [assembly: AssemblyCopyright("Copyright © 2011, The Outercurve Foundation")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. //[assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM //[assembly: Guid("77870c51-c5f2-4c33-891e-1a2f1777bb09")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.1.0.0")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: InternalsVisibleTo("SimpleJson.Tests")] ================================================ FILE: src/SimpleJson/SimpleJson-Net20.csproj ================================================  Debug AnyCPU 8.0.30703 2.0 {02523326-C4CA-45B1-9C1B-2438D218A5C0} Library Properties SimpleJson SimpleJson v2.0 512 true full false ..\..\bin\Net20\Debug\ TRACE;DEBUG;SIMPLE_JSON_NO_LINQ_EXPRESSION; prompt 4 AnyCPU ISO-2 pdbonly true ..\..\bin\Net20\Release\ TRACE;SIMPLE_JSON_NO_LINQ_EXPRESSION; prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-Net35.csproj ================================================  Debug AnyCPU 8.0.30703 2.0 {5033CD0A-483B-4E41-87A2-D0F65905B5D3} Library Properties SimpleJson SimpleJson v3.5 512 Client true full false ..\..\bin\Net35\Debug\ TRACE;DEBUG prompt 4 pdbonly true ..\..\bin\Net35\Release\ TRACE prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-Net40.csproj ================================================  Debug AnyCPU 8.0.30703 2.0 {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99} Library Properties SimpleJson SimpleJson v4.0 512 Client true full false ..\..\bin\Net40\Debug\ TRACE;DEBUG;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_DYNAMIC; prompt 4 pdbonly true ..\..\bin\Net40\Release\ TRACE;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_DYNAMIC; prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-Net45.csproj ================================================  Debug AnyCPU {19F83E93-3679-4A93-8E3B-707050A96E85} Library Properties SimpleJson SimpleJson-Net45 v4.5 512 true full false ..\..\bin\Net45\Debug\ TRACE;DEBUG;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_DYNAMIC;SIMPLE_JSON_READONLY_COLLECTIONS prompt 4 pdbonly true ..\..\bin\Net45\Release\ TRACE;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_DYNAMIC;SIMPLE_JSON_READONLY_COLLECTIONS prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-Portable-NoLinqExpression.csproj ================================================  10.0 Debug AnyCPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A} Library Properties SimpleJson SimpleJson-Portable-NoLinqExpression v4.0 Profile136 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4.0 true full false ..\..\bin\PCL-NOLINQ\Debug\ TRACE;DEBUG;SIMPLE_JSON_NO_LINQ_EXPRESSION;SIMPLE_JSON_DATACONTRACT; prompt 4 ISO-2 pdbonly true ..\..\bin\PCL-NOLINQ\Release\ TRACE;SIMPLE_JSON_NO_LINQ_EXPRESSION;SIMPLE_JSON_DATACONTRACT; prompt 4 ISO-2 ================================================ FILE: src/SimpleJson/SimpleJson-Portable-WP8WinStoreNet45.csproj ================================================  11.0 Debug AnyCPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C} Library Properties SimpleJson_Portable_WP8WinStoreNet45 SimpleJson-Portable-WP8WinStoreNet45 v4.5 Profile78 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true full false ..\..\bin\PCLiWP8WinStoreNet45\Debug\ TRACE;DEBUG;SIMPLE_JSON_TYPEINFO;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_READONLY_COLLECTIONS prompt 4 pdbonly true ..\..\bin\PCLiWP8WinStoreNet45\Release\ TRACE;SIMPLE_JSON_TYPEINFO;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_READONLY_COLLECTIONS prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-Portable.csproj ================================================  10.0 Debug AnyCPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC} Library Properties SimpleJson SimpleJson-Portable v4.0 Profile136 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4.0 true full false ..\..\bin\PCL\Debug\ TRACE;DEBUG;SIMPLE_JSON_DATACONTRACT; prompt 4 ISO-2 pdbonly true ..\..\bin\PCL\Release\ TRACE;SIMPLE_JSON_DATACONTRACT; prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-SL4.csproj ================================================  Debug AnyCPU 8.0.50727 2.0 {4A93FDBA-28DD-4737-B0DF-72CF0C42D962} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties SimpleJson SimpleJson Silverlight v4.0 $(TargetFrameworkVersion) false true true v3.5 true full false ..\..\bin\SL4\Debug\ TRACE;DEBUG;SILVERLIGHT;SIMPLE_JSON_DYNAMIC; true true prompt 4 pdbonly true ..\..\bin\SL4\Release\ TRACE;SILVERLIGHT;SIMPLE_JSON_DYNAMIC; true true prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-SL5.csproj ================================================  Debug AnyCPU 8.0.50727 2.0 {F918711A-6A76-488E-8990-0F0B73E1F532} {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties SimpleJson SimpleJson Silverlight v5.0 $(TargetFrameworkVersion) false true true v3.5 true full false ..\..\bin\SL5\Debug\ TRACE;DEBUG;SILVERLIGHT;SIMPLE_JSON_DYNAMIC; true true prompt 4 pdbonly true ..\..\bin\SL5\Release\ TRACE;SILVERLIGHT;SIMPLE_JSON_DYNAMIC; true true prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-WP7.csproj ================================================  Debug AnyCPU 10.0.20506 2.0 {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6} {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties SimpleJson SimpleJson v4.0 $(TargetFrameworkVersion) WindowsPhone Silverlight false true true true full false ..\..\bin\WP7\Debug\ TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_NO_LINQ_EXPRESSION; true true prompt 4 pdbonly true ..\..\bin\WP7\Release\ TRACE;SILVERLIGHT;WINDOWS_PHONE;SIMPLE_JSON_DATACONTRACT;SIMPLE_JSON_NO_LINQ_EXPRESSION; true true prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-WP71.csproj ================================================  Debug AnyCPU 10.0.20506 2.0 {954977A1-6134-4F60-A0B7-FF041828E267} {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties SimpleJson_WP71 SimpleJson-WP71 v4.0 $(TargetFrameworkVersion) WindowsPhone71 Silverlight false true true true full false ..\..\bin\WP71\Debug\ TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;SIMPLE_JSON_DATACONTRACT; true true prompt 4 pdbonly true ..\..\bin\WP71\Release\ TRACE;SILVERLIGHT;WINDOWS_PHONE;SIMPLE_JSON_DATACONTRACT; true true prompt 4 ================================================ FILE: src/SimpleJson/SimpleJson-WindowsStore.csproj ================================================  Debug AnyCPU 8.0.30703 2.0 {95427DE1-88B5-4679-9D96-B7AC4739A7FA} Library Properties SimpleJson SimpleJson-WindowsStore en-US 512 {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true full false bin\Debug\ DEBUG;TRACE;NETFX_CORE prompt 4 pdbonly true bin\Release\ TRACE;NETFX_CORE prompt 4 true bin\ARM\Debug\ DEBUG;TRACE;NETFX_CORE ;2008 full ARM false prompt true bin\ARM\Release\ TRACE;NETFX_CORE true ;2008 pdbonly ARM false prompt true true bin\x64\Debug\ DEBUG;TRACE;NETFX_CORE ;2008 full x64 false prompt true bin\x64\Release\ TRACE;NETFX_CORE true ;2008 pdbonly x64 false prompt true true ..\..\bin\WindowsStore\Debug\ TRACE;DEBUG;NETFX_CORE;SIMPLE_JSON_DYNAMIC;SIMPLE_JSON_DATACONTRACT; ;2008 full x86 false prompt true ..\..\bin\WindowsStore\Release\ TRACE;NETFX_CORE;SIMPLE_JSON_DYNAMIC;SIMPLE_JSON_DATACONTRACT; true ;2008 pdbonly x86 false prompt true 12.0 ================================================ FILE: src/SimpleJson/SimpleJson.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- // VERSION: // NOTE: uncomment the following line to make SimpleJson class internal. //#define SIMPLE_JSON_INTERNAL // NOTE: uncomment the following line to make JsonArray and JsonObject class internal. //#define SIMPLE_JSON_OBJARRAYINTERNAL // NOTE: uncomment the following line to enable dynamic support. //#define SIMPLE_JSON_DYNAMIC // NOTE: uncomment the following line to enable DataContract support. //#define SIMPLE_JSON_DATACONTRACT // NOTE: uncomment the following line to enable IReadOnlyCollection and IReadOnlyList support. //#define SIMPLE_JSON_READONLY_COLLECTIONS // NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke(). // define if you are using .net framework <= 3.0 or < WP7.5 //#define SIMPLE_JSON_NO_LINQ_EXPRESSION // NOTE: uncomment the following line if you are compiling under Window Metro style application/library. // usually already defined in properties //#define NETFX_CORE; // If you are targetting WinStore, WP8 and NET4.5+ PCL make sure to #define SIMPLE_JSON_TYPEINFO; // original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html #if NETFX_CORE #define SIMPLE_JSON_TYPEINFO #endif using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; #if !SIMPLE_JSON_NO_LINQ_EXPRESSION using System.Linq.Expressions; #endif using System.ComponentModel; using System.Diagnostics.CodeAnalysis; #if SIMPLE_JSON_DYNAMIC using System.Dynamic; #endif using System.Globalization; using System.Reflection; using System.Runtime.Serialization; using System.Text; using SimpleJson.Reflection; // ReSharper disable LoopCanBeConvertedToQuery // ReSharper disable RedundantExplicitArrayCreation // ReSharper disable SuggestUseVarKeywordEvident namespace SimpleJson { /// /// Represents the json array. /// [GeneratedCode("simple-json", "1.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] #if SIMPLE_JSON_OBJARRAYINTERNAL internal #else public #endif class JsonArray : List { /// /// Initializes a new instance of the class. /// public JsonArray() { } /// /// Initializes a new instance of the class. /// /// The capacity of the json array. public JsonArray(int capacity) : base(capacity) { } /// /// The json representation of the array. /// /// The json representation of the array. public override string ToString() { return SimpleJson.SerializeObject(this) ?? string.Empty; } } /// /// Represents the json object. /// [GeneratedCode("simple-json", "1.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] #if SIMPLE_JSON_OBJARRAYINTERNAL internal #else public #endif class JsonObject : #if SIMPLE_JSON_DYNAMIC DynamicObject, #endif IDictionary { /// /// The internal member dictionary. /// private readonly Dictionary _members; /// /// Initializes a new instance of . /// public JsonObject() { _members = new Dictionary(); } /// /// Initializes a new instance of . /// /// The implementation to use when comparing keys, or null to use the default for the type of the key. public JsonObject(IEqualityComparer comparer) { _members = new Dictionary(comparer); } /// /// Gets the at the specified index. /// /// public object this[int index] { get { return GetAtIndex(_members, index); } } internal static object GetAtIndex(IDictionary obj, int index) { if (obj == null) throw new ArgumentNullException("obj"); if (index >= obj.Count) throw new ArgumentOutOfRangeException("index"); int i = 0; foreach (KeyValuePair o in obj) if (i++ == index) return o.Value; return null; } /// /// Adds the specified key. /// /// The key. /// The value. public void Add(string key, object value) { _members.Add(key, value); } /// /// Determines whether the specified key contains key. /// /// The key. /// /// true if the specified key contains key; otherwise, false. /// public bool ContainsKey(string key) { return _members.ContainsKey(key); } /// /// Gets the keys. /// /// The keys. public ICollection Keys { get { return _members.Keys; } } /// /// Removes the specified key. /// /// The key. /// public bool Remove(string key) { return _members.Remove(key); } /// /// Tries the get value. /// /// The key. /// The value. /// public bool TryGetValue(string key, out object value) { return _members.TryGetValue(key, out value); } /// /// Gets the values. /// /// The values. public ICollection Values { get { return _members.Values; } } /// /// Gets or sets the with the specified key. /// /// public object this[string key] { get { return _members[key]; } set { _members[key] = value; } } /// /// Adds the specified item. /// /// The item. public void Add(KeyValuePair item) { _members.Add(item.Key, item.Value); } /// /// Clears this instance. /// public void Clear() { _members.Clear(); } /// /// Determines whether [contains] [the specified item]. /// /// The item. /// /// true if [contains] [the specified item]; otherwise, false. /// public bool Contains(KeyValuePair item) { return _members.ContainsKey(item.Key) && _members[item.Key] == item.Value; } /// /// Copies to. /// /// The array. /// Index of the array. public void CopyTo(KeyValuePair[] array, int arrayIndex) { if (array == null) throw new ArgumentNullException("array"); int num = Count; foreach (KeyValuePair kvp in this) { array[arrayIndex++] = kvp; if (--num <= 0) return; } } /// /// Gets the count. /// /// The count. public int Count { get { return _members.Count; } } /// /// Gets a value indicating whether this instance is read only. /// /// /// true if this instance is read only; otherwise, false. /// public bool IsReadOnly { get { return false; } } /// /// Removes the specified item. /// /// The item. /// public bool Remove(KeyValuePair item) { return _members.Remove(item.Key); } /// /// Gets the enumerator. /// /// public IEnumerator> GetEnumerator() { return _members.GetEnumerator(); } /// /// Returns an enumerator that iterates through a collection. /// /// /// An object that can be used to iterate through the collection. /// IEnumerator IEnumerable.GetEnumerator() { return _members.GetEnumerator(); } /// /// Returns a json that represents the current . /// /// /// A json that represents the current . /// public override string ToString() { return SimpleJson.SerializeObject(this); } #if SIMPLE_JSON_DYNAMIC /// /// Provides implementation for type conversion operations. Classes derived from the class can override this method to specify dynamic behavior for operations that convert an object from one type to another. /// /// Provides information about the conversion operation. The binder.Type property provides the type to which the object must be converted. For example, for the statement (String)sampleObject in C# (CType(sampleObject, Type) in Visual Basic), where sampleObject is an instance of the class derived from the class, binder.Type returns the type. The binder.Explicit property provides information about the kind of conversion that occurs. It returns true for explicit conversion and false for implicit conversion. /// The result of the type conversion operation. /// /// Alwasy returns true. /// public override bool TryConvert(ConvertBinder binder, out object result) { // if (binder == null) throw new ArgumentNullException("binder"); // Type targetType = binder.Type; if ((targetType == typeof(IEnumerable)) || (targetType == typeof(IEnumerable>)) || (targetType == typeof(IDictionary)) || (targetType == typeof(IDictionary))) { result = this; return true; } return base.TryConvert(binder, out result); } /// /// Provides the implementation for operations that delete an object member. This method is not intended for use in C# or Visual Basic. /// /// Provides information about the deletion. /// /// Alwasy returns true. /// public override bool TryDeleteMember(DeleteMemberBinder binder) { // if (binder == null) throw new ArgumentNullException("binder"); // return _members.Remove(binder.Name); } /// /// Provides the implementation for operations that get a value by index. Classes derived from the class can override this method to specify dynamic behavior for indexing operations. /// /// Provides information about the operation. /// The indexes that are used in the operation. For example, for the sampleObject[3] operation in C# (sampleObject(3) in Visual Basic), where sampleObject is derived from the DynamicObject class, is equal to 3. /// The result of the index operation. /// /// Alwasy returns true. /// public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { if (indexes == null) throw new ArgumentNullException("indexes"); if (indexes.Length == 1) { result = ((IDictionary)this)[(string)indexes[0]]; return true; } result = null; return true; } /// /// Provides the implementation for operations that get member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as getting a value for a property. /// /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. /// The result of the get operation. For example, if the method is called for a property, you can assign the property value to . /// /// Alwasy returns true. /// public override bool TryGetMember(GetMemberBinder binder, out object result) { object value; if (_members.TryGetValue(binder.Name, out value)) { result = value; return true; } result = null; return true; } /// /// Provides the implementation for operations that set a value by index. Classes derived from the class can override this method to specify dynamic behavior for operations that access objects by a specified index. /// /// Provides information about the operation. /// The indexes that are used in the operation. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 3. /// The value to set to the object that has the specified index. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the class, is equal to 10. /// /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown. /// public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) { if (indexes == null) throw new ArgumentNullException("indexes"); if (indexes.Length == 1) { ((IDictionary)this)[(string)indexes[0]] = value; return true; } return base.TrySetIndex(binder, indexes, value); } /// /// Provides the implementation for operations that set member values. Classes derived from the class can override this method to specify dynamic behavior for operations such as setting a value for a property. /// /// Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. /// The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the class, the is "Test". /// /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.) /// public override bool TrySetMember(SetMemberBinder binder, object value) { // if (binder == null) throw new ArgumentNullException("binder"); // _members[binder.Name] = value; return true; } /// /// Returns the enumeration of all dynamic member names. /// /// /// A sequence that contains dynamic member names. /// public override IEnumerable GetDynamicMemberNames() { foreach (var key in Keys) yield return key; } #endif } } namespace SimpleJson { /// /// This class encodes and decodes JSON strings. /// Spec. details, see http://www.json.org/ /// /// JSON uses Arrays and Objects. These correspond here to the datatypes JsonArray(IList<object>) and JsonObject(IDictionary<string,object>). /// All numbers are parsed to doubles. /// [GeneratedCode("simple-json", "1.0.0")] #if SIMPLE_JSON_INTERNAL internal #else public #endif static class SimpleJson { private const int TOKEN_NONE = 0; private const int TOKEN_CURLY_OPEN = 1; private const int TOKEN_CURLY_CLOSE = 2; private const int TOKEN_SQUARED_OPEN = 3; private const int TOKEN_SQUARED_CLOSE = 4; private const int TOKEN_COLON = 5; private const int TOKEN_COMMA = 6; private const int TOKEN_STRING = 7; private const int TOKEN_NUMBER = 8; private const int TOKEN_TRUE = 9; private const int TOKEN_FALSE = 10; private const int TOKEN_NULL = 11; private const int BUILDER_CAPACITY = 2000; private static readonly char[] EscapeTable; private static readonly char[] EscapeCharacters = new char[] { '"', '\\', '\b', '\f', '\n', '\r', '\t' }; private static readonly string EscapeCharactersString = new string(EscapeCharacters); static SimpleJson() { EscapeTable = new char[93]; EscapeTable['"'] = '"'; EscapeTable['\\'] = '\\'; EscapeTable['\b'] = 'b'; EscapeTable['\f'] = 'f'; EscapeTable['\n'] = 'n'; EscapeTable['\r'] = 'r'; EscapeTable['\t'] = 't'; } /// /// Parses the string json into a value /// /// A JSON string. /// An IList<object>, a IDictionary<string,object>, a double, a string, null, true, or false public static object DeserializeObject(string json) { object obj; if (TryDeserializeObject(json, out obj)) return obj; throw new SerializationException("Invalid JSON string"); } /// /// Try parsing the json string into a value. /// /// /// A JSON string. /// /// /// The object. /// /// /// Returns true if successfull otherwise false. /// [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] public static bool TryDeserializeObject(string json, out object obj) { bool success = true; if (json != null) { char[] charArray = json.ToCharArray(); int index = 0; obj = ParseValue(charArray, ref index, ref success); } else obj = null; return success; } public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy) { object jsonObject = DeserializeObject(json); return type == null || jsonObject != null && ReflectionUtils.IsAssignableFrom(jsonObject.GetType(), type) ? jsonObject : (jsonSerializerStrategy ?? CurrentJsonSerializerStrategy).DeserializeObject(jsonObject, type); } public static object DeserializeObject(string json, Type type) { return DeserializeObject(json, type, null); } public static T DeserializeObject(string json, IJsonSerializerStrategy jsonSerializerStrategy) { return (T)DeserializeObject(json, typeof(T), jsonSerializerStrategy); } public static T DeserializeObject(string json) { return (T)DeserializeObject(json, typeof(T), null); } /// /// Converts a IDictionary<string,object> / IList<object> object into a JSON string /// /// A IDictionary<string,object> / IList<object> /// Serializer strategy to use /// A JSON encoded string, or null if object 'json' is not serializable public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy) { StringBuilder builder = new StringBuilder(BUILDER_CAPACITY); bool success = SerializeValue(jsonSerializerStrategy, json, builder); return (success ? builder.ToString() : null); } public static string SerializeObject(object json) { return SerializeObject(json, CurrentJsonSerializerStrategy); } public static string EscapeToJavascriptString(string jsonString) { if (string.IsNullOrEmpty(jsonString)) return jsonString; StringBuilder sb = new StringBuilder(); char c; for (int i = 0; i < jsonString.Length; ) { c = jsonString[i++]; if (c == '\\') { int remainingLength = jsonString.Length - i; if (remainingLength >= 2) { char lookahead = jsonString[i]; if (lookahead == '\\') { sb.Append('\\'); ++i; } else if (lookahead == '"') { sb.Append("\""); ++i; } else if (lookahead == 't') { sb.Append('\t'); ++i; } else if (lookahead == 'b') { sb.Append('\b'); ++i; } else if (lookahead == 'n') { sb.Append('\n'); ++i; } else if (lookahead == 'r') { sb.Append('\r'); ++i; } } } else { sb.Append(c); } } return sb.ToString(); } static IDictionary ParseObject(char[] json, ref int index, ref bool success) { IDictionary table = new JsonObject(); int token; // { NextToken(json, ref index); bool done = false; while (!done) { token = LookAhead(json, index); if (token == TOKEN_NONE) { success = false; return null; } else if (token == TOKEN_COMMA) NextToken(json, ref index); else if (token == TOKEN_CURLY_CLOSE) { NextToken(json, ref index); return table; } else { // name string name = ParseString(json, ref index, ref success); if (!success) { success = false; return null; } // : token = NextToken(json, ref index); if (token != TOKEN_COLON) { success = false; return null; } // value object value = ParseValue(json, ref index, ref success); if (!success) { success = false; return null; } table[name] = value; } } return table; } static JsonArray ParseArray(char[] json, ref int index, ref bool success) { JsonArray array = new JsonArray(); // [ NextToken(json, ref index); bool done = false; while (!done) { int token = LookAhead(json, index); if (token == TOKEN_NONE) { success = false; return null; } else if (token == TOKEN_COMMA) NextToken(json, ref index); else if (token == TOKEN_SQUARED_CLOSE) { NextToken(json, ref index); break; } else { object value = ParseValue(json, ref index, ref success); if (!success) return null; array.Add(value); } } return array; } static object ParseValue(char[] json, ref int index, ref bool success) { switch (LookAhead(json, index)) { case TOKEN_STRING: return ParseString(json, ref index, ref success); case TOKEN_NUMBER: return ParseNumber(json, ref index, ref success); case TOKEN_CURLY_OPEN: return ParseObject(json, ref index, ref success); case TOKEN_SQUARED_OPEN: return ParseArray(json, ref index, ref success); case TOKEN_TRUE: NextToken(json, ref index); return true; case TOKEN_FALSE: NextToken(json, ref index); return false; case TOKEN_NULL: NextToken(json, ref index); return null; case TOKEN_NONE: break; } success = false; return null; } static string ParseString(char[] json, ref int index, ref bool success) { StringBuilder s = new StringBuilder(BUILDER_CAPACITY); char c; EatWhitespace(json, ref index); // " c = json[index++]; bool complete = false; while (!complete) { if (index == json.Length) break; c = json[index++]; if (c == '"') { complete = true; break; } else if (c == '\\') { if (index == json.Length) break; c = json[index++]; if (c == '"') s.Append('"'); else if (c == '\\') s.Append('\\'); else if (c == '/') s.Append('/'); else if (c == 'b') s.Append('\b'); else if (c == 'f') s.Append('\f'); else if (c == 'n') s.Append('\n'); else if (c == 'r') s.Append('\r'); else if (c == 't') s.Append('\t'); else if (c == 'u') { int remainingLength = json.Length - index; if (remainingLength >= 4) { // parse the 32 bit hex into an integer codepoint uint codePoint; if (!(success = UInt32.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codePoint))) return ""; // convert the integer codepoint to a unicode char and add to string if (0xD800 <= codePoint && codePoint <= 0xDBFF) // if high surrogate { index += 4; // skip 4 chars remainingLength = json.Length - index; if (remainingLength >= 6) { uint lowCodePoint; if (new string(json, index, 2) == "\\u" && UInt32.TryParse(new string(json, index + 2, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out lowCodePoint)) { if (0xDC00 <= lowCodePoint && lowCodePoint <= 0xDFFF) // if low surrogate { s.Append((char)codePoint); s.Append((char)lowCodePoint); index += 6; // skip 6 chars continue; } } } success = false; // invalid surrogate pair return ""; } s.Append(ConvertFromUtf32((int)codePoint)); // skip 4 chars index += 4; } else break; } } else s.Append(c); } if (!complete) { success = false; return null; } return s.ToString(); } private static string ConvertFromUtf32(int utf32) { // http://www.java2s.com/Open-Source/CSharp/2.6.4-mono-.net-core/System/System/Char.cs.htm if (utf32 < 0 || utf32 > 0x10FFFF) throw new ArgumentOutOfRangeException("utf32", "The argument must be from 0 to 0x10FFFF."); if (0xD800 <= utf32 && utf32 <= 0xDFFF) throw new ArgumentOutOfRangeException("utf32", "The argument must not be in surrogate pair range."); if (utf32 < 0x10000) return new string((char)utf32, 1); utf32 -= 0x10000; return new string(new char[] { (char)((utf32 >> 10) + 0xD800), (char)(utf32 % 0x0400 + 0xDC00) }); } static object ParseNumber(char[] json, ref int index, ref bool success) { EatWhitespace(json, ref index); int lastIndex = GetLastIndexOfNumber(json, index); int charLength = (lastIndex - index) + 1; object returnNumber; string str = new string(json, index, charLength); if (str.IndexOf(".", StringComparison.OrdinalIgnoreCase) != -1 || str.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1) { double number; success = double.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); returnNumber = number; } else { long number; success = long.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); returnNumber = number; } index = lastIndex + 1; return returnNumber; } static int GetLastIndexOfNumber(char[] json, int index) { int lastIndex; for (lastIndex = index; lastIndex < json.Length; lastIndex++) if ("0123456789+-.eE".IndexOf(json[lastIndex]) == -1) break; return lastIndex - 1; } static void EatWhitespace(char[] json, ref int index) { for (; index < json.Length; index++) if (" \t\n\r\b\f".IndexOf(json[index]) == -1) break; } static int LookAhead(char[] json, int index) { int saveIndex = index; return NextToken(json, ref saveIndex); } [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] static int NextToken(char[] json, ref int index) { EatWhitespace(json, ref index); if (index == json.Length) return TOKEN_NONE; char c = json[index]; index++; switch (c) { case '{': return TOKEN_CURLY_OPEN; case '}': return TOKEN_CURLY_CLOSE; case '[': return TOKEN_SQUARED_OPEN; case ']': return TOKEN_SQUARED_CLOSE; case ',': return TOKEN_COMMA; case '"': return TOKEN_STRING; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '-': return TOKEN_NUMBER; case ':': return TOKEN_COLON; } index--; int remainingLength = json.Length - index; // false if (remainingLength >= 5) { if (json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e') { index += 5; return TOKEN_FALSE; } } // true if (remainingLength >= 4) { if (json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e') { index += 4; return TOKEN_TRUE; } } // null if (remainingLength >= 4) { if (json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l') { index += 4; return TOKEN_NULL; } } return TOKEN_NONE; } static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder) { bool success = true; string stringValue = value as string; if (stringValue != null) success = SerializeString(stringValue, builder); else { IDictionary dict = value as IDictionary; if (dict != null) { success = SerializeObject(jsonSerializerStrategy, dict.Keys, dict.Values, builder); } else { IDictionary stringDictionary = value as IDictionary; if (stringDictionary != null) { success = SerializeObject(jsonSerializerStrategy, stringDictionary.Keys, stringDictionary.Values, builder); } else { IEnumerable enumerableValue = value as IEnumerable; if (enumerableValue != null) success = SerializeArray(jsonSerializerStrategy, enumerableValue, builder); else if (IsNumeric(value)) success = SerializeNumber(value, builder); else if (value is bool) builder.Append((bool)value ? "true" : "false"); else if (value == null) builder.Append("null"); else { object serializedObject; success = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out serializedObject); if (success) SerializeValue(jsonSerializerStrategy, serializedObject, builder); } } } } return success; } static bool SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder) { builder.Append("{"); IEnumerator ke = keys.GetEnumerator(); IEnumerator ve = values.GetEnumerator(); bool first = true; while (ke.MoveNext() && ve.MoveNext()) { object key = ke.Current; object value = ve.Current; if (!first) builder.Append(","); string stringKey = key as string; if (stringKey != null) SerializeString(stringKey, builder); else if (!SerializeValue(jsonSerializerStrategy, value, builder)) return false; builder.Append(":"); if (!SerializeValue(jsonSerializerStrategy, value, builder)) return false; first = false; } builder.Append("}"); return true; } static bool SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder) { builder.Append("["); bool first = true; foreach (object value in anArray) { if (!first) builder.Append(","); if (!SerializeValue(jsonSerializerStrategy, value, builder)) return false; first = false; } builder.Append("]"); return true; } static bool SerializeString(string aString, StringBuilder builder) { // Happy path if there's nothing to be escaped. IndexOfAny is highly optimized (and unmanaged) if (aString.IndexOfAny(EscapeCharacters) == -1) { builder.Append('"'); builder.Append(aString); builder.Append('"'); return true; } builder.Append('"'); int safeCharacterCount = 0; char[] charArray = aString.ToCharArray(); for (int i = 0; i < charArray.Length; i++) { char c = charArray[i]; // Non ascii characters are fine, buffer them up and send them to the builder // in larger chunks if possible. The escape table is a 1:1 translation table // with \0 [default(char)] denoting a safe character. if (c >= EscapeTable.Length || EscapeTable[c] == default(char)) { safeCharacterCount++; } else { if (safeCharacterCount > 0) { builder.Append(charArray, i - safeCharacterCount, safeCharacterCount); safeCharacterCount = 0; } builder.Append('\\'); builder.Append(EscapeTable[c]); } } if (safeCharacterCount > 0) { builder.Append(charArray, charArray.Length - safeCharacterCount, safeCharacterCount); } builder.Append('"'); return true; } static bool SerializeNumber(object number, StringBuilder builder) { if (number is long) builder.Append(((long)number).ToString(CultureInfo.InvariantCulture)); else if (number is ulong) builder.Append(((ulong)number).ToString(CultureInfo.InvariantCulture)); else if (number is int) builder.Append(((int)number).ToString(CultureInfo.InvariantCulture)); else if (number is uint) builder.Append(((uint)number).ToString(CultureInfo.InvariantCulture)); else if (number is decimal) builder.Append(((decimal)number).ToString(CultureInfo.InvariantCulture)); else if (number is float) builder.Append(((float)number).ToString(CultureInfo.InvariantCulture)); else builder.Append(Convert.ToDouble(number, CultureInfo.InvariantCulture).ToString("r", CultureInfo.InvariantCulture)); return true; } /// /// Determines if a given object is numeric in any way /// (can be integer, double, null, etc). /// static bool IsNumeric(object value) { if (value is sbyte) return true; if (value is byte) return true; if (value is short) return true; if (value is ushort) return true; if (value is int) return true; if (value is uint) return true; if (value is long) return true; if (value is ulong) return true; if (value is float) return true; if (value is double) return true; if (value is decimal) return true; return false; } private static IJsonSerializerStrategy _currentJsonSerializerStrategy; public static IJsonSerializerStrategy CurrentJsonSerializerStrategy { get { return _currentJsonSerializerStrategy ?? (_currentJsonSerializerStrategy = #if SIMPLE_JSON_DATACONTRACT DataContractJsonSerializerStrategy #else PocoJsonSerializerStrategy #endif ); } set { _currentJsonSerializerStrategy = value; } } private static PocoJsonSerializerStrategy _pocoJsonSerializerStrategy; [EditorBrowsable(EditorBrowsableState.Advanced)] public static PocoJsonSerializerStrategy PocoJsonSerializerStrategy { get { return _pocoJsonSerializerStrategy ?? (_pocoJsonSerializerStrategy = new PocoJsonSerializerStrategy()); } } #if SIMPLE_JSON_DATACONTRACT private static DataContractJsonSerializerStrategy _dataContractJsonSerializerStrategy; [System.ComponentModel.EditorBrowsable(EditorBrowsableState.Advanced)] public static DataContractJsonSerializerStrategy DataContractJsonSerializerStrategy { get { return _dataContractJsonSerializerStrategy ?? (_dataContractJsonSerializerStrategy = new DataContractJsonSerializerStrategy()); } } #endif } [GeneratedCode("simple-json", "1.0.0")] #if SIMPLE_JSON_INTERNAL internal #else public #endif interface IJsonSerializerStrategy { [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] bool TrySerializeNonPrimitiveObject(object input, out object output); object DeserializeObject(object value, Type type); } [GeneratedCode("simple-json", "1.0.0")] #if SIMPLE_JSON_INTERNAL internal #else public #endif class PocoJsonSerializerStrategy : IJsonSerializerStrategy { internal IDictionary ConstructorCache; internal IDictionary> GetCache; internal IDictionary>> SetCache; internal static readonly Type[] EmptyTypes = new Type[0]; internal static readonly Type[] ArrayConstructorParameterTypes = new Type[] { typeof(int) }; private static readonly string[] Iso8601Format = new string[] { @"yyyy-MM-dd\THH:mm:ss.FFFFFFF\Z", @"yyyy-MM-dd\THH:mm:ss\Z", @"yyyy-MM-dd\THH:mm:ssK" }; public PocoJsonSerializerStrategy() { ConstructorCache = new ReflectionUtils.ThreadSafeDictionary(ContructorDelegateFactory); GetCache = new ReflectionUtils.ThreadSafeDictionary>(GetterValueFactory); SetCache = new ReflectionUtils.ThreadSafeDictionary>>(SetterValueFactory); } protected virtual string MapClrMemberNameToJsonFieldName(string clrPropertyName) { return clrPropertyName; } internal virtual ReflectionUtils.ConstructorDelegate ContructorDelegateFactory(Type key) { return ReflectionUtils.GetContructor(key, key.IsArray ? ArrayConstructorParameterTypes : EmptyTypes); } internal virtual IDictionary GetterValueFactory(Type type) { IDictionary result = new Dictionary(); foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) { if (propertyInfo.CanRead) { MethodInfo getMethod = ReflectionUtils.GetGetterMethodInfo(propertyInfo); if (getMethod.IsStatic || !getMethod.IsPublic) continue; result[MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = ReflectionUtils.GetGetMethod(propertyInfo); } } foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) { if (fieldInfo.IsStatic || !fieldInfo.IsPublic) continue; result[MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = ReflectionUtils.GetGetMethod(fieldInfo); } return result; } internal virtual IDictionary> SetterValueFactory(Type type) { IDictionary> result = new Dictionary>(); foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) { if (propertyInfo.CanWrite) { MethodInfo setMethod = ReflectionUtils.GetSetterMethodInfo(propertyInfo); if (setMethod.IsStatic || !setMethod.IsPublic) continue; result[MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = new KeyValuePair(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo)); } } foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) { if (fieldInfo.IsInitOnly || fieldInfo.IsStatic || !fieldInfo.IsPublic) continue; result[MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = new KeyValuePair(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo)); } return result; } public virtual bool TrySerializeNonPrimitiveObject(object input, out object output) { return TrySerializeKnownTypes(input, out output) || TrySerializeUnknownTypes(input, out output); } [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] public virtual object DeserializeObject(object value, Type type) { if (type == null) throw new ArgumentNullException("type"); string str = value as string; if (type == typeof (Guid) && string.IsNullOrEmpty(str)) return default(Guid); if (value == null) return null; object obj = null; if (str != null) { if (str.Length != 0) // We know it can't be null now. { if (type == typeof(DateTime) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTime))) return DateTime.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); if (type == typeof(DateTimeOffset) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTimeOffset))) return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid))) return new Guid(str); if (type == typeof(Uri)) { bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute); Uri result; if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result)) return result; return null; } if (type == typeof(string)) return str; return Convert.ChangeType(str, type, CultureInfo.InvariantCulture); } else { if (type == typeof(Guid)) obj = default(Guid); else if (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)) obj = null; else obj = str; } // Empty string case if (!ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)) return str; } else if (value is bool) return value; bool valueIsLong = value is long; bool valueIsDouble = value is double; if ((valueIsLong && type == typeof(long)) || (valueIsDouble && type == typeof(double))) return value; if ((valueIsDouble && type != typeof(double)) || (valueIsLong && type != typeof(long))) { obj = type == typeof(int) || type == typeof(long) || type == typeof(double) || type == typeof(float) || type == typeof(bool) || type == typeof(decimal) || type == typeof(byte) || type == typeof(short) ? Convert.ChangeType(value, type, CultureInfo.InvariantCulture) : value; } else { IDictionary objects = value as IDictionary; if (objects != null) { IDictionary jsonObject = objects; if (ReflectionUtils.IsTypeDictionary(type)) { // if dictionary then Type[] types = ReflectionUtils.GetGenericTypeArguments(type); Type keyType = types[0]; Type valueType = types[1]; Type genericType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType); IDictionary dict = (IDictionary)ConstructorCache[genericType](); foreach (KeyValuePair kvp in jsonObject) dict.Add(kvp.Key, DeserializeObject(kvp.Value, valueType)); obj = dict; } else { if (type == typeof(object)) obj = value; else { obj = ConstructorCache[type](); foreach (KeyValuePair> setter in SetCache[type]) { object jsonValue; if (jsonObject.TryGetValue(setter.Key, out jsonValue)) { jsonValue = DeserializeObject(jsonValue, setter.Value.Key); setter.Value.Value(obj, jsonValue); } } } } } else { IList valueAsList = value as IList; if (valueAsList != null) { IList jsonObject = valueAsList; IList list = null; if (type.IsArray) { list = (IList)ConstructorCache[type](jsonObject.Count); int i = 0; foreach (object o in jsonObject) list[i++] = DeserializeObject(o, type.GetElementType()); } else if (ReflectionUtils.IsTypeGenericeCollectionInterface(type) || ReflectionUtils.IsAssignableFrom(typeof(IList), type)) { Type innerType = ReflectionUtils.GetGenericListElementType(type); list = (IList)(ConstructorCache[type] ?? ConstructorCache[typeof(List<>).MakeGenericType(innerType)])(jsonObject.Count); foreach (object o in jsonObject) list.Add(DeserializeObject(o, innerType)); } obj = list; } } return obj; } if (ReflectionUtils.IsNullableType(type)) return ReflectionUtils.ToNullableType(obj, type); return obj; } protected virtual object SerializeEnum(Enum p) { return Convert.ToDouble(p, CultureInfo.InvariantCulture); } [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] protected virtual bool TrySerializeKnownTypes(object input, out object output) { bool returnValue = true; if (input is DateTime) output = ((DateTime)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture); else if (input is DateTimeOffset) output = ((DateTimeOffset)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture); else if (input is Guid) output = ((Guid)input).ToString("D"); else if (input is Uri) output = input.ToString(); else { Enum inputEnum = input as Enum; if (inputEnum != null) output = SerializeEnum(inputEnum); else { returnValue = false; output = null; } } return returnValue; } [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")] protected virtual bool TrySerializeUnknownTypes(object input, out object output) { if (input == null) throw new ArgumentNullException("input"); output = null; Type type = input.GetType(); if (type.FullName == null) return false; IDictionary obj = new JsonObject(); IDictionary getters = GetCache[type]; foreach (KeyValuePair getter in getters) { if (getter.Value != null) obj.Add(MapClrMemberNameToJsonFieldName(getter.Key), getter.Value(input)); } output = obj; return true; } } #if SIMPLE_JSON_DATACONTRACT [GeneratedCode("simple-json", "1.0.0")] #if SIMPLE_JSON_INTERNAL internal #else public #endif class DataContractJsonSerializerStrategy : PocoJsonSerializerStrategy { public DataContractJsonSerializerStrategy() { GetCache = new ReflectionUtils.ThreadSafeDictionary>(GetterValueFactory); SetCache = new ReflectionUtils.ThreadSafeDictionary>>(SetterValueFactory); } internal override IDictionary GetterValueFactory(Type type) { bool hasDataContract = ReflectionUtils.GetAttribute(type, typeof(DataContractAttribute)) != null; if (!hasDataContract) return base.GetterValueFactory(type); string jsonKey; IDictionary result = new Dictionary(); foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) { if (propertyInfo.CanRead) { MethodInfo getMethod = ReflectionUtils.GetGetterMethodInfo(propertyInfo); if (!getMethod.IsStatic && CanAdd(propertyInfo, out jsonKey)) result[jsonKey] = ReflectionUtils.GetGetMethod(propertyInfo); } } foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) { if (!fieldInfo.IsStatic && CanAdd(fieldInfo, out jsonKey)) result[jsonKey] = ReflectionUtils.GetGetMethod(fieldInfo); } return result; } internal override IDictionary> SetterValueFactory(Type type) { bool hasDataContract = ReflectionUtils.GetAttribute(type, typeof(DataContractAttribute)) != null; if (!hasDataContract) return base.SetterValueFactory(type); string jsonKey; IDictionary> result = new Dictionary>(); foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type)) { if (propertyInfo.CanWrite) { MethodInfo setMethod = ReflectionUtils.GetSetterMethodInfo(propertyInfo); if (!setMethod.IsStatic && CanAdd(propertyInfo, out jsonKey)) result[jsonKey] = new KeyValuePair(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo)); } } foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type)) { if (!fieldInfo.IsInitOnly && !fieldInfo.IsStatic && CanAdd(fieldInfo, out jsonKey)) result[jsonKey] = new KeyValuePair(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo)); } // todo implement sorting for DATACONTRACT. return result; } private static bool CanAdd(MemberInfo info, out string jsonKey) { jsonKey = null; if (ReflectionUtils.GetAttribute(info, typeof(IgnoreDataMemberAttribute)) != null) return false; DataMemberAttribute dataMemberAttribute = (DataMemberAttribute)ReflectionUtils.GetAttribute(info, typeof(DataMemberAttribute)); if (dataMemberAttribute == null) return false; jsonKey = string.IsNullOrEmpty(dataMemberAttribute.Name) ? info.Name : dataMemberAttribute.Name; return true; } } #endif namespace Reflection { // This class is meant to be copied into other libraries. So we want to exclude it from Code Analysis rules // that might be in place in the target project. [GeneratedCode("reflection-utils", "1.0.0")] #if SIMPLE_JSON_REFLECTION_UTILS_PUBLIC public #else internal #endif class ReflectionUtils { private static readonly object[] EmptyObjects = new object[] { }; public delegate object GetDelegate(object source); public delegate void SetDelegate(object source, object value); public delegate object ConstructorDelegate(params object[] args); public delegate TValue ThreadSafeDictionaryValueFactory(TKey key); #if SIMPLE_JSON_TYPEINFO public static TypeInfo GetTypeInfo(Type type) { return type.GetTypeInfo(); } #else public static Type GetTypeInfo(Type type) { return type; } #endif public static Attribute GetAttribute(MemberInfo info, Type type) { #if SIMPLE_JSON_TYPEINFO if (info == null || type == null || !info.IsDefined(type)) return null; return info.GetCustomAttribute(type); #else if (info == null || type == null || !Attribute.IsDefined(info, type)) return null; return Attribute.GetCustomAttribute(info, type); #endif } public static Type GetGenericListElementType(Type type) { IEnumerable interfaces; #if SIMPLE_JSON_TYPEINFO interfaces = type.GetTypeInfo().ImplementedInterfaces; #else interfaces = type.GetInterfaces(); #endif foreach (Type implementedInterface in interfaces) { if (IsTypeGeneric(implementedInterface) && implementedInterface.GetGenericTypeDefinition() == typeof (IList<>)) { return GetGenericTypeArguments(implementedInterface)[0]; } } return GetGenericTypeArguments(type)[0]; } public static Attribute GetAttribute(Type objectType, Type attributeType) { #if SIMPLE_JSON_TYPEINFO if (objectType == null || attributeType == null || !objectType.GetTypeInfo().IsDefined(attributeType)) return null; return objectType.GetTypeInfo().GetCustomAttribute(attributeType); #else if (objectType == null || attributeType == null || !Attribute.IsDefined(objectType, attributeType)) return null; return Attribute.GetCustomAttribute(objectType, attributeType); #endif } public static Type[] GetGenericTypeArguments(Type type) { #if SIMPLE_JSON_TYPEINFO return type.GetTypeInfo().GenericTypeArguments; #else return type.GetGenericArguments(); #endif } public static bool IsTypeGeneric(Type type) { return GetTypeInfo(type).IsGenericType; } public static bool IsTypeGenericeCollectionInterface(Type type) { if (!IsTypeGeneric(type)) return false; Type genericDefinition = type.GetGenericTypeDefinition(); return (genericDefinition == typeof(IList<>) || genericDefinition == typeof(ICollection<>) || genericDefinition == typeof(IEnumerable<>) #if SIMPLE_JSON_READONLY_COLLECTIONS || genericDefinition == typeof(IReadOnlyCollection<>) || genericDefinition == typeof(IReadOnlyList<>) #endif ); } public static bool IsAssignableFrom(Type type1, Type type2) { return GetTypeInfo(type1).IsAssignableFrom(GetTypeInfo(type2)); } public static bool IsTypeDictionary(Type type) { #if SIMPLE_JSON_TYPEINFO if (typeof(IDictionary<,>).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) return true; #else if (typeof(System.Collections.IDictionary).IsAssignableFrom(type)) return true; #endif if (!GetTypeInfo(type).IsGenericType) return false; Type genericDefinition = type.GetGenericTypeDefinition(); return genericDefinition == typeof(IDictionary<,>); } public static bool IsNullableType(Type type) { return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); } public static object ToNullableType(object obj, Type nullableType) { return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture); } public static bool IsValueType(Type type) { return GetTypeInfo(type).IsValueType; } public static IEnumerable GetConstructors(Type type) { #if SIMPLE_JSON_TYPEINFO return type.GetTypeInfo().DeclaredConstructors; #else return type.GetConstructors(); #endif } public static ConstructorInfo GetConstructorInfo(Type type, params Type[] argsType) { IEnumerable constructorInfos = GetConstructors(type); int i; bool matches; foreach (ConstructorInfo constructorInfo in constructorInfos) { ParameterInfo[] parameters = constructorInfo.GetParameters(); if (argsType.Length != parameters.Length) continue; i = 0; matches = true; foreach (ParameterInfo parameterInfo in constructorInfo.GetParameters()) { if (parameterInfo.ParameterType != argsType[i]) { matches = false; break; } } if (matches) return constructorInfo; } return null; } public static IEnumerable GetProperties(Type type) { #if SIMPLE_JSON_TYPEINFO return type.GetRuntimeProperties(); #else return type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); #endif } public static IEnumerable GetFields(Type type) { #if SIMPLE_JSON_TYPEINFO return type.GetRuntimeFields(); #else return type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); #endif } public static MethodInfo GetGetterMethodInfo(PropertyInfo propertyInfo) { #if SIMPLE_JSON_TYPEINFO return propertyInfo.GetMethod; #else return propertyInfo.GetGetMethod(true); #endif } public static MethodInfo GetSetterMethodInfo(PropertyInfo propertyInfo) { #if SIMPLE_JSON_TYPEINFO return propertyInfo.SetMethod; #else return propertyInfo.GetSetMethod(true); #endif } public static ConstructorDelegate GetContructor(ConstructorInfo constructorInfo) { #if SIMPLE_JSON_NO_LINQ_EXPRESSION return GetConstructorByReflection(constructorInfo); #else return GetConstructorByExpression(constructorInfo); #endif } public static ConstructorDelegate GetContructor(Type type, params Type[] argsType) { #if SIMPLE_JSON_NO_LINQ_EXPRESSION return GetConstructorByReflection(type, argsType); #else return GetConstructorByExpression(type, argsType); #endif } public static ConstructorDelegate GetConstructorByReflection(ConstructorInfo constructorInfo) { return delegate(object[] args) { return constructorInfo.Invoke(args); }; } public static ConstructorDelegate GetConstructorByReflection(Type type, params Type[] argsType) { ConstructorInfo constructorInfo = GetConstructorInfo(type, argsType); return constructorInfo == null ? null : GetConstructorByReflection(constructorInfo); } #if !SIMPLE_JSON_NO_LINQ_EXPRESSION public static ConstructorDelegate GetConstructorByExpression(ConstructorInfo constructorInfo) { ParameterInfo[] paramsInfo = constructorInfo.GetParameters(); ParameterExpression param = Expression.Parameter(typeof(object[]), "args"); Expression[] argsExp = new Expression[paramsInfo.Length]; for (int i = 0; i < paramsInfo.Length; i++) { Expression index = Expression.Constant(i); Type paramType = paramsInfo[i].ParameterType; Expression paramAccessorExp = Expression.ArrayIndex(param, index); Expression paramCastExp = Expression.Convert(paramAccessorExp, paramType); argsExp[i] = paramCastExp; } NewExpression newExp = Expression.New(constructorInfo, argsExp); Expression> lambda = Expression.Lambda>(newExp, param); Func compiledLambda = lambda.Compile(); return delegate(object[] args) { return compiledLambda(args); }; } public static ConstructorDelegate GetConstructorByExpression(Type type, params Type[] argsType) { ConstructorInfo constructorInfo = GetConstructorInfo(type, argsType); return constructorInfo == null ? null : GetConstructorByExpression(constructorInfo); } #endif public static GetDelegate GetGetMethod(PropertyInfo propertyInfo) { #if SIMPLE_JSON_NO_LINQ_EXPRESSION return GetGetMethodByReflection(propertyInfo); #else return GetGetMethodByExpression(propertyInfo); #endif } public static GetDelegate GetGetMethod(FieldInfo fieldInfo) { #if SIMPLE_JSON_NO_LINQ_EXPRESSION return GetGetMethodByReflection(fieldInfo); #else return GetGetMethodByExpression(fieldInfo); #endif } public static GetDelegate GetGetMethodByReflection(PropertyInfo propertyInfo) { MethodInfo methodInfo = GetGetterMethodInfo(propertyInfo); return delegate(object source) { return methodInfo.Invoke(source, EmptyObjects); }; } public static GetDelegate GetGetMethodByReflection(FieldInfo fieldInfo) { return delegate(object source) { return fieldInfo.GetValue(source); }; } #if !SIMPLE_JSON_NO_LINQ_EXPRESSION public static GetDelegate GetGetMethodByExpression(PropertyInfo propertyInfo) { MethodInfo getMethodInfo = GetGetterMethodInfo(propertyInfo); ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType); Func compiled = Expression.Lambda>(Expression.TypeAs(Expression.Call(instanceCast, getMethodInfo), typeof(object)), instance).Compile(); return delegate(object source) { return compiled(source); }; } public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo) { ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); MemberExpression member = Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo); GetDelegate compiled = Expression.Lambda(Expression.Convert(member, typeof(object)), instance).Compile(); return delegate(object source) { return compiled(source); }; } #endif public static SetDelegate GetSetMethod(PropertyInfo propertyInfo) { #if SIMPLE_JSON_NO_LINQ_EXPRESSION return GetSetMethodByReflection(propertyInfo); #else return GetSetMethodByExpression(propertyInfo); #endif } public static SetDelegate GetSetMethod(FieldInfo fieldInfo) { #if SIMPLE_JSON_NO_LINQ_EXPRESSION return GetSetMethodByReflection(fieldInfo); #else return GetSetMethodByExpression(fieldInfo); #endif } public static SetDelegate GetSetMethodByReflection(PropertyInfo propertyInfo) { MethodInfo methodInfo = GetSetterMethodInfo(propertyInfo); return delegate(object source, object value) { methodInfo.Invoke(source, new object[] { value }); }; } public static SetDelegate GetSetMethodByReflection(FieldInfo fieldInfo) { return delegate(object source, object value) { fieldInfo.SetValue(source, value); }; } #if !SIMPLE_JSON_NO_LINQ_EXPRESSION public static SetDelegate GetSetMethodByExpression(PropertyInfo propertyInfo) { MethodInfo setMethodInfo = GetSetterMethodInfo(propertyInfo); ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); ParameterExpression value = Expression.Parameter(typeof(object), "value"); UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType); UnaryExpression valueCast = (!IsValueType(propertyInfo.PropertyType)) ? Expression.TypeAs(value, propertyInfo.PropertyType) : Expression.Convert(value, propertyInfo.PropertyType); Action compiled = Expression.Lambda>(Expression.Call(instanceCast, setMethodInfo, valueCast), new ParameterExpression[] { instance, value }).Compile(); return delegate(object source, object val) { compiled(source, val); }; } public static SetDelegate GetSetMethodByExpression(FieldInfo fieldInfo) { ParameterExpression instance = Expression.Parameter(typeof(object), "instance"); ParameterExpression value = Expression.Parameter(typeof(object), "value"); Action compiled = Expression.Lambda>( Assign(Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo), Expression.Convert(value, fieldInfo.FieldType)), instance, value).Compile(); return delegate(object source, object val) { compiled(source, val); }; } public static BinaryExpression Assign(Expression left, Expression right) { #if SIMPLE_JSON_TYPEINFO return Expression.Assign(left, right); #else MethodInfo assign = typeof(Assigner<>).MakeGenericType(left.Type).GetMethod("Assign"); BinaryExpression assignExpr = Expression.Add(left, right, assign); return assignExpr; #endif } private static class Assigner { public static T Assign(ref T left, T right) { return (left = right); } } #endif public sealed class ThreadSafeDictionary : IDictionary { private readonly object _lock = new object(); private readonly ThreadSafeDictionaryValueFactory _valueFactory; private Dictionary _dictionary; public ThreadSafeDictionary(ThreadSafeDictionaryValueFactory valueFactory) { _valueFactory = valueFactory; } private TValue Get(TKey key) { if (_dictionary == null) return AddValue(key); TValue value; if (!_dictionary.TryGetValue(key, out value)) return AddValue(key); return value; } private TValue AddValue(TKey key) { TValue value = _valueFactory(key); lock (_lock) { if (_dictionary == null) { _dictionary = new Dictionary(); _dictionary[key] = value; } else { TValue val; if (_dictionary.TryGetValue(key, out val)) return val; Dictionary dict = new Dictionary(_dictionary); dict[key] = value; _dictionary = dict; } } return value; } public void Add(TKey key, TValue value) { throw new NotImplementedException(); } public bool ContainsKey(TKey key) { return _dictionary.ContainsKey(key); } public ICollection Keys { get { return _dictionary.Keys; } } public bool Remove(TKey key) { throw new NotImplementedException(); } public bool TryGetValue(TKey key, out TValue value) { value = this[key]; return true; } public ICollection Values { get { return _dictionary.Values; } } public TValue this[TKey key] { get { return Get(key); } set { throw new NotImplementedException(); } } public void Add(KeyValuePair item) { throw new NotImplementedException(); } public void Clear() { throw new NotImplementedException(); } public bool Contains(KeyValuePair item) { throw new NotImplementedException(); } public void CopyTo(KeyValuePair[] array, int arrayIndex) { throw new NotImplementedException(); } public int Count { get { return _dictionary.Count; } } public bool IsReadOnly { get { throw new NotImplementedException(); } } public bool Remove(KeyValuePair item) { throw new NotImplementedException(); } public IEnumerator> GetEnumerator() { return _dictionary.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return _dictionary.GetEnumerator(); } } } } } // ReSharper restore LoopCanBeConvertedToQuery // ReSharper restore RedundantExplicitArrayCreation // ReSharper restore SuggestUseVarKeywordEvident ================================================ FILE: src/SimpleJson.Tests/DataContractTests/DataContractSampleClassess.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir ShresTha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { using System.Runtime.Serialization; #region Fields [DataContract] public class DataContractPublicReadOnlyFields { [DataMember] public readonly string DataMemberWithoutName = "dmv"; [DataMember(Name = "name")] public readonly string DatMemberWithName = "dmnv"; [IgnoreDataMember] public readonly string IgnoreDataMember = "idm"; public readonly string NoDataMember = "ndm"; } [DataContract] public class DataContractPublicFields { [DataMember] public string DataMemberWithoutName = "dmv"; [DataMember(Name = "name")] public string DatMemberWithName = "dmnv"; [IgnoreDataMember] public string IgnoreDataMember = "idm"; public string NoDataMember = "ndm"; } // Supress is assigned by its value is never used #pragma warning disable 0414 [DataContract] public class DataContractPrivateReadOnlyFields { [DataMember] private readonly string DataMemberWithoutName = "dmv"; [DataMember(Name = "name")] private readonly string DatMemberWithName = "dmnv"; [IgnoreDataMember] private readonly string IgnoreDataMember = "idm"; private readonly string NoDataMember = "ndm"; } [DataContract] public class DataContractPrivateFields { [DataMember] private string DataMemberWithoutName = "dmv"; [DataMember(Name = "name")] private string DatMemberWithName = "dmnv"; [IgnoreDataMember] private string IgnoreDataMember = "idm"; private string NoDataMember = "ndm"; } #pragma warning restore 0414 #endregion #region Getter [DataContract] public class DataContractPublicGetters { [DataMember] public string DataMemberWithoutName { get { return "dmv"; } } [DataMember(Name = "name")] public string DatMemberWithName { get { return "dmnv"; } } [IgnoreDataMember] public string IgnoreDataMember { get { return "idm"; } } public string NoDataMember { get { return "ndm"; } } } [DataContract] public class DataContractPrivateGetters { [DataMember] private string DataMemberWithoutName { get { return "dmv"; } } [DataMember(Name = "name")] private string DatMemberWithName { get { return "dmnv"; } } [IgnoreDataMember] private string IgnoreDataMember { get { return "idm"; } } private string NoDataMember { get { return "ndm"; } } } #endregion #region Setter [DataContract] public class DataContractPublicSetters { [DataMember] public string DataMemberWithoutName { set { } } [DataMember(Name = "name")] public string DatMemberWithName { set { } } [IgnoreDataMember] public string IgnoreDataMember { set { } } public string NoDataMember { set { } } } [DataContract] public class DataContractPrivateSetters { [DataMember] private string DataMemberWithoutName { set { } } [DataMember(Name = "name")] private string DatMemberWithName { set { } } [IgnoreDataMember] private string IgnoreDataMember { set { } } private string NoDataMember { set { } } } #endregion #region Getter/Setters [DataContract] public class DataContractPublicGetterSetters { public DataContractPublicGetterSetters() { DataMemberWithoutName = "dmv"; DatMemberWithName = "dmnv"; IgnoreDataMember = "idm"; NoDataMember = "ndm"; } [DataMember] public string DataMemberWithoutName { get; set; } [DataMember(Name = "name")] public string DatMemberWithName { get; set; } [IgnoreDataMember] public string IgnoreDataMember { get; set; } public string NoDataMember { get; set; } } [DataContract] public class DataContractPrivateGetterSetters { public DataContractPrivateGetterSetters() { DataMemberWithoutName = "dmv"; DatMemberWithName = "dmnv"; IgnoreDataMember = "idm"; NoDataMember = "ndm"; } [DataMember] private string DataMemberWithoutName { get; set; } [DataMember(Name = "name")] private string DatMemberWithName { get; set; } [IgnoreDataMember] private string IgnoreDataMember { get; set; } private string NoDataMember { get; set; } } #endregion } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PrivateFieldsSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PrivateFieldsSerializeTests { private DataContractPrivateFields _dataContractPrivateFields; public PrivateFieldsSerializeTests() { _dataContractPrivateFields = new DataContractPrivateFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateFields, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PrivateGetterSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PrivateGetterSettersSerializeTests { private DataContractPrivateGetterSetters _dataContractPrivateGetterSetters; public PrivateGetterSettersSerializeTests() { _dataContractPrivateGetterSetters = new DataContractPrivateGetterSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateGetterSetters, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PrivateGettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PrivateGettersSerializeTests { private DataContractPrivateGetters _dataContractPrivateGetters; public PrivateGettersSerializeTests() { _dataContractPrivateGetters = new DataContractPrivateGetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateGetters, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PrivateReadonlySerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PrivateReadonlySerializeTests { private DataContractPrivateReadOnlyFields _dataContractPrivateReadOnlyFields; public PrivateReadonlySerializeTests() { _dataContractPrivateReadOnlyFields = new DataContractPrivateReadOnlyFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateReadOnlyFields, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PrivateSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PrivateSettersSerializeTests { private DataContractPrivateSetters _dataContractPrivateSetters; public PrivateSettersSerializeTests() { _dataContractPrivateSetters = new DataContractPrivateSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateSetters, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PublicFieldsSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PublicFieldsSerializeTests { private DataContractPublicFields _dataContractPublicFields; public PublicFieldsSerializeTests() { _dataContractPublicFields = new DataContractPublicFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicFields, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PublicGetterSetterDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { using System.Collections.Generic; using System.Runtime.Serialization; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PublicGetterSetterDeserializeTests { [TestMethod] public void DeserializesCorrectly() { var json = "{\"DataMemberWithoutName\":\"1\",\"name\":\"2\"}"; var obj = new DataContractPublicGetterSetters(); var result = (DataContractPublicGetterSetters)SimpleJson.DeserializeObject(json, typeof(DataContractPublicGetterSetters), SimpleJson.DataContractJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual("1", result.DataMemberWithoutName); Assert.AreEqual("2", result.DatMemberWithName); Assert.AreEqual(obj.IgnoreDataMember, result.IgnoreDataMember); Assert.AreEqual(obj.NoDataMember, result.NoDataMember); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PublicGetterSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PublicGetterSettersSerializeTests { private DataContractPublicGetterSetters _dataContractPublicGetterSetters; public PublicGetterSettersSerializeTests() { _dataContractPublicGetterSetters = new DataContractPublicGetterSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicGetterSetters, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PublicGettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PublicGettersSerializeTests { private DataContractPublicGetters _contractPublicGetters; public PublicGettersSerializeTests() { _contractPublicGetters = new DataContractPublicGetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_contractPublicGetters, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PublicReadonlySerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PublicReadonlySerializeTests { private DataContractPublicReadOnlyFields _dataContractPublicReadOnlyFields; public PublicReadonlySerializeTests() { _dataContractPublicReadOnlyFields = new DataContractPublicReadOnlyFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicReadOnlyFields, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"name\":\"dmnv\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DataContractTests/PublicSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.DataContractTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class PublicSettersSerializeTests { private DataContractPublicSetters _dataContractPublicSetters; public PublicSettersSerializeTests() { _dataContractPublicSetters = new DataContractPublicSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicSetters, SimpleJson.DataContractJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/DeserializeGenericListTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System; using System.Collections.Generic; using System.Runtime.Serialization; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class DeserializeGenericListTests { private class NumberList : List { } private class ItemList : List { } private class Item { public string SomeProperty { get; set; } } [TestMethod] public void Can_Deserialize_Root_Json_Array_Of_Primitives_To_Inherited_List() { var json = "[0,1,2]"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count); for (int i = 0; i < 3; i++) { Assert.AreEqual(i, result[i]); } } [TestMethod] public void Can_Deserialize_Root_Json_Array_Of_Primitives_To_Generic_List() { var json = "[0,1,2]"; var result = SimpleJson.DeserializeObject>(json); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count); for (int i = 0; i < 3; i++) { Assert.AreEqual(i, result[i]); } } [TestMethod] public void Can_Deserialize_Root_Json_Array_To_Inherited_List() { var json = @"[{""SomeProperty"":""bar0""},{""SomeProperty"":""bar1""}]"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("bar0", result[0].SomeProperty); Assert.AreEqual("bar1", result[1].SomeProperty); } } } ================================================ FILE: src/SimpleJson.Tests/DeserializeObjectTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System; using System.Collections.Generic; using System.Runtime.Serialization; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class DeserializeObjectTests { public class ObjProp { public string PropTypeKnown { get; set; } public object PropTypeUnknown { get; set; } } [TestMethod] public void ReadIndented() { string input = @"{ ""CPU"": ""Intel"", ""Drives"": [ ""DVD read/writer"", ""500 gigabyte hard drive"" ] }"; object obj = SimpleJson.DeserializeObject(input); #if NETFX_CORE Assert.IsInstanceOfType(obj, typeof(IDictionary)); Assert.IsInstanceOfType(obj, typeof(JsonObject)); #else Assert.IsInstanceOf>(obj); Assert.IsInstanceOf(obj); #endif var root = (IDictionary)obj; Assert.AreEqual(2, root.Count); Assert.IsTrue(root.ContainsKey("CPU")); Assert.AreEqual("Intel", root["CPU"]); Assert.IsTrue(root.ContainsKey("Drives")); #if NETFX_CORE Assert.IsInstanceOfType(root["Drives"], typeof(IList)); Assert.IsInstanceOfType(root["Drives"], typeof(JsonArray)); #else Assert.IsInstanceOf>(root["Drives"]); Assert.IsInstanceOf(root["Drives"]); #endif var drives = (IList)root["Drives"]; Assert.AreEqual(2, drives.Count); #if NETFX_CORE Assert.IsInstanceOfType(drives[0], typeof(string)); #else Assert.IsInstanceOf(drives[0]); #endif Assert.AreEqual("DVD read/writer", drives[0]); #if NETFX_CORE Assert.IsInstanceOfType(drives[1], typeof(string)); #else Assert.IsInstanceOf(drives[1]); #endif Assert.AreEqual("500 gigabyte hard drive", drives[1]); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void UnexpectedEndOfString() { var result = SimpleJson.DeserializeObject("hi"); } #endif [TestMethod] public void ReadNullTerminiatorString() { var result = SimpleJson.DeserializeObject("\"h\0i\""); Assert.AreEqual("h\0i", result); } [TestMethod] public void EmptyObjectDeserialize() { var result = SimpleJson.DeserializeObject("{}"); #if NETFX_CORE Assert.IsInstanceOfType(result, typeof(IDictionary)); #else Assert.IsInstanceOf>(result); #endif var dict = (IDictionary) result; Assert.AreEqual(0, dict.Count); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void UnexpectedEndOfHex() { var result = SimpleJson.DeserializeObject(@"'h\u006"); } [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void UnexpectedEndOfControlCharacter() { var result = SimpleJson.DeserializeObject(@"'h\"); } [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void UnexpectedEndWhenParsingUnquotedProperty() { var result = SimpleJson.DeserializeObject(@"{aww"); } #endif [TestMethod] public void ParsingQuotedPropertyWithControlCharacters() { var result = SimpleJson.DeserializeObject("{\"hi\r\nbye\":1}"); #if NETFX_CORE Assert.IsInstanceOfType(result, typeof(IDictionary)); Assert.IsInstanceOfType(result, typeof(JsonObject)); #else Assert.IsInstanceOf>(result); Assert.IsInstanceOf(result); #endif var dict = (IDictionary)result; foreach (KeyValuePair pair in dict) { Assert.AreEqual(@"hi bye", pair.Key); } } [TestMethod] public void ReadNewLineLastCharacter() { string input = @"{ ""CPU"": ""Intel"", ""Drives"": [ ""DVD read/writer"", ""500 gigabyte hard drive"" ] }" + '\n'; object o = SimpleJson.DeserializeObject(input); Assert.IsNotNull(o); #if NETFX_CORE Assert.IsInstanceOfType(o, typeof(IDictionary)); #else Assert.IsInstanceOf>(o); #endif var dict = (IDictionary)o; Assert.AreEqual("Intel", dict["CPU"]); } [TestMethod] #if NETFX_CORE [Ignore] #else [Ignore("not part of the json standard.")] #endif public void FloatingPointNonFiniteNumber() { string input = @"[ NaN, Infinity, -Infinity ]"; var o = SimpleJson.DeserializeObject(input); } [TestMethod] public void LongStringTests() { int length = 20000; string json = @"[""" + new string(' ', length) + @"""]"; var o = SimpleJson.DeserializeObject(json); var a = (IList)o; #if NETFX_CORE Assert.IsInstanceOfType(a[0], typeof(string)); #else Assert.IsInstanceOf(a[0]); #endif Assert.AreEqual(20000, ((string)a[0]).Length); } [TestMethod] public void EscapedUnicodeTests() { string json = @"[""\u003c"",""\u5f20""]"; var o = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(o, typeof(List)); #else Assert.IsInstanceOf>(o); #endif var l = (List)o; Assert.AreEqual(2, l.Count); Assert.AreEqual("<", l[0]); //Assert.AreEqual("24352", Convert.ToInt32(Convert.ToChar(l[0]))); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void MissingColon() { string json = @"{ ""A"" : true, ""B"" ""hello"", // Notice the colon is missing ""C"" : ""bye"" }"; var o = SimpleJson.DeserializeObject(json); } [TestMethod] #if NETFX_CORE [Ignore] #else [Ignore("not part of the json standard.")] #endif public void ReadOcatalNumber() { var json = @"[0372, 0xFA, 0XFA]"; var o = SimpleJson.DeserializeObject(json); } #endif [TestMethod] public void ReadUnicode() { string json = @"{""Message"":""Hi,I\u0092ve send you smth""}"; var o = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(o, typeof(IDictionary)); Assert.IsInstanceOfType(o, typeof(JsonObject)); #else Assert.IsInstanceOf>(o); Assert.IsInstanceOf(o); #endif var dict = (IDictionary)o; Assert.AreEqual(@"Hi,I" + '\u0092' + "ve send you smth", dict["Message"]); } [TestMethod] public void DeserializeUnicodeChar() { string json = "\"न\""; var o = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(o, typeof(string)); #else Assert.IsInstanceOf(o); #endif Assert.AreEqual("न", o); } [TestMethod] #if NETFX_CORE [Ignore] #else [Ignore("not part of the json standard.")] #endif public void ReadHexidecimalWithAllLetters() { string json = @"{""text"":0xabcdef12345}"; var o = SimpleJson.DeserializeObject(json); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void ParseIncompleteArray() { var o = SimpleJson.DeserializeObject("[1"); } #endif [TestMethod] public void DeserializeSurrogatePair() { string json = "\"𩸽 is Arabesque greenling(fish) in japanese\""; var o = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(o, typeof(string)); #else Assert.IsInstanceOf(o); #endif Assert.AreEqual("𩸽 is Arabesque greenling(fish) in japanese", o); } [TestMethod] public void DeserializeEscapedSurrogatePair() { string json = "\"\\uD867\\uDE3D is Arabesque greenling(fish)\""; // 𩸽 var o = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(o, typeof(string)); #else Assert.IsInstanceOf(o); #endif Assert.AreEqual("\uD867\uDE3D is Arabesque greenling(fish)", o); Assert.AreEqual("𩸽 is Arabesque greenling(fish)", o); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(SerializationException), #if !NETFX_CORE ExpectedMessage = #endif "Invalid JSON string")] public void DeserializeInvaildEscapedSurrogatePair() { string json = "\"\\uD867\\u0000 is Arabesque greenling(fish)\""; var o = SimpleJson.DeserializeObject(json); } #endif [TestMethod] public void DeserializeKnownJsonObjectType() { var json = "{\"FirstName\":\"Bruno\",\"LastName\":\"Baïa\",\"Address\":{\"Country\":\"France\",\"City\":\"Toulouse\"}}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.AreEqual("Bruno", result["FirstName"]); Assert.AreEqual("Baïa", result["LastName"]); var address = result["Address"] as JsonObject; Assert.AreEqual("France", address["Country"]); Assert.AreEqual("Toulouse", address["City"]); } [TestMethod] public void DeserializeKnownJsonObjectTypeWithMapping() { const string json = "{\"first_name\":\"Bruno\",\"LastName\":\"Mars\"}"; var result = SimpleJson.DeserializeObject(json, new MySerializationStrategy()); Assert.IsNotNull(result); Assert.AreEqual("Bruno", result.FirstName); Assert.AreEqual("Mars", result.LastName); } private class MySerializationStrategy : PocoJsonSerializerStrategy { protected override string MapClrMemberNameToJsonFieldName(string jsonFieldName) { return jsonFieldName == "FirstName" ? "first_name" : jsonFieldName; } } public class Sample { public string FirstName { get; set; } public string LastName { get; set; } } [TestMethod] public void DeserializeKnownJsonArrayType() { var json = "[{\"name\":\"road cycling\",\"value\":11},{\"name\":\"football\",\"value\":9}]"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); foreach (JsonObject hobby in result) { #if NETFX_CORE Assert.IsNotNull(hobby["name"]); Assert.IsNotNull(hobby["value"]); #else Assert.NotNull(hobby["name"]); Assert.NotNull(hobby["value"]); #endif } } [TestMethod] public void DeserializeDoubleQuotesCorrectly() { var json = "{\"message\":\"Hi \\\"Prabir\\\"\"}"; var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.AreEqual("Hi \"Prabir\"", result["message"]); } class ClassWithUri { public Uri url { get; set; } } [TestMethod] public void DeserializeUriCorrectly() { var json = "{\"url\":\"https://github.com/shiftkey/simple-json/issues/1\"}"; var result = SimpleJson.DeserializeObject(json); Assert.AreEqual(new Uri("https://github.com/shiftkey/simple-json/issues/1"), result.url); } [TestMethod] public void DeserializeInvalidUriCorrectly() { var json = "{\"url\":\"this is a broken uri\"}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNull(result.url); } [TestMethod] public void DeserializeUnknownProperty() { var json = "{\"PropTypeKnown\":\"str\",\"PropTypeUnknown\":{\"unknown\":\"property\"}}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.AreEqual("str", result.PropTypeKnown); #if NETFX_CORE Assert.IsInstanceOfType(result.PropTypeUnknown, typeof(IDictionary)); Assert.IsInstanceOfType(result.PropTypeUnknown, typeof(JsonObject)); #else Assert.IsInstanceOf>(result.PropTypeUnknown); Assert.IsInstanceOf(result.PropTypeUnknown); #endif var dict = (IDictionary)result.PropTypeUnknown; Assert.IsNotNull(dict); Assert.AreEqual(1, dict.Count); Assert.AreEqual("property", dict["unknown"]); } public class BaseClass { public string B { get; set; } } public class SomeClass : BaseClass { public string A { get; set; } } [TestMethod] public void DeserializePropertiesOnBaseClass() { var json = "{\"A\":\"first-value\",\"B\":\"another-value\"}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.AreEqual("first-value", result.A); Assert.AreEqual("another-value", result.B); } } } ================================================ FILE: src/SimpleJson.Tests/EscapeToJavascriptStringTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class EscapeToJavascriptStringTests { [TestMethod] public void BackSlash() { var serialized = SimpleJson.SerializeObject("c:\\haha.pl"); var result = SimpleJson.EscapeToJavascriptString(serialized); Assert.AreEqual("\"c:\\haha.pl\"", result); } [TestMethod] public void BackSlashWithT() { var serialized = SimpleJson.SerializeObject("c:\\taha.pl"); var result = SimpleJson.EscapeToJavascriptString(serialized); Assert.AreEqual("\"c:\\taha.pl\"", result); } } } ================================================ FILE: src/SimpleJson.Tests/JsonArrayTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System; using System.Collections.Generic; using System.Runtime.Serialization; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class JsonArrayTests { [TestMethod] public void Clear() { JsonArray a = new JsonArray { 1 }; Assert.AreEqual(1, a.Count); a.Clear(); Assert.AreEqual(0, a.Count); } [TestMethod] public void Contains() { int v = 1; JsonArray a = new JsonArray { v }; Assert.IsFalse(a.Contains(2)); Assert.IsFalse(a.Contains(null)); Assert.IsTrue(a.Contains(v)); } [TestMethod] public void Remove() { object v = 1; JsonArray j = new JsonArray(); j.Add(v); Assert.AreEqual(1, j.Count); Assert.AreEqual(false, j.Remove(2)); Assert.AreEqual(false, j.Remove(null)); Assert.AreEqual(true, j.Remove(v)); Assert.AreEqual(false, j.Remove(v)); Assert.AreEqual(0, j.Count); } [TestMethod] public void IndexOf() { object v1 = 1; object v2 = 2; object v3 = 3; JsonArray j = new JsonArray(); j.Add(v1); Assert.AreEqual(0, j.IndexOf(v1)); j.Add(v2); Assert.AreEqual(0, j.IndexOf(v1)); Assert.AreEqual(1, j.IndexOf(v2)); } [TestMethod] public void RemoveAt() { object v1 = 1; object v2 = 2; object v3 = 3; JsonArray j = new JsonArray(); j.Add(v1); j.Add(v2); j.Add(v3); Assert.AreEqual(true, j.Contains(v1)); j.RemoveAt(0); Assert.AreEqual(false, j.Contains(v1)); Assert.AreEqual(true, j.Contains(v3)); j.RemoveAt(1); Assert.AreEqual(false, j.Contains(v3)); Assert.AreEqual(1, j.Count); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(ArgumentOutOfRangeException), #if !NETFX_CORE ExpectedMessage = #endif @"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index")] public void RemoveAtOutOfRangeIndexShouldBeError() { JsonArray j = new JsonArray(); j.RemoveAt(0); } [TestMethod] [ExpectedException(typeof(ArgumentOutOfRangeException), #if !NETFX_CORE ExpectedMessage = #endif @"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index")] public void RemoveNegtiveIndexShouldBeError() { JsonArray j = new JsonArray(); j.RemoveAt(-1); } #endif [TestMethod] public void Insert() { object v1 = 1; object v2 = 2; object v3 = 3; object v4 = 4; JsonArray j = new JsonArray(); j.Add(v1); j.Add(v2); j.Add(v3); j.Insert(1, v4); Assert.AreEqual(0, j.IndexOf(v1)); Assert.AreEqual(1, j.IndexOf(v4)); Assert.AreEqual(2, j.IndexOf(v2)); Assert.AreEqual(3, j.IndexOf(v3)); } [TestMethod] public void InsertShouldInsertAtZeroIndex() { object v1 = 1; object v2 = 2; JsonArray j = new JsonArray(); j.Insert(0, v1); Assert.AreEqual(0, j.IndexOf(v1)); j.Insert(0, v2); Assert.AreEqual(1, j.IndexOf(v1)); Assert.AreEqual(0, j.IndexOf(v2)); } [TestMethod] public void InsertNull() { JsonArray j = new JsonArray(); j.Insert(0, null); Assert.AreEqual(null, j[0]); } #if !NETFX_CORE [TestMethod] [ExpectedException(typeof(ArgumentOutOfRangeException), #if !NETFX_CORE ExpectedMessage = #endif @"Index must be within the bounds of the List. Parameter name: index")] public void InsertNegativeIndexShouldThrow() { JsonArray j = new JsonArray(); j.Insert(-1, 1); } [TestMethod] [ExpectedException(typeof(ArgumentOutOfRangeException), #if !NETFX_CORE ExpectedMessage = #endif @"Index must be within the bounds of the List. Parameter name: index")] public void InsertOutOfRangeIndexShouldThrow() { JsonArray j = new JsonArray(); j.Insert(2, 1); } #endif [TestMethod] public void Item() { object v1 = 1; object v2 = 2; object v3 = 3; object v4 = 4; JsonArray j = new JsonArray(); j.Add(v1); j.Add(v2); j.Add(v3); j[1] = v4; Assert.AreEqual(-1, j.IndexOf(v2)); Assert.AreEqual(1, j.IndexOf(v4)); } [TestMethod] public void Iterate() { JsonArray a = new JsonArray { 1, 2, 3, 4, 5 }; int i = 1; foreach (object o in a) { Assert.AreEqual(i, o); ++i; } } } } ================================================ FILE: src/SimpleJson.Tests/JsonDataContractSerializeObjectTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System.Collections.Generic; using System.Runtime.Serialization; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class JsonDataContractSerializeObjectTests { [DataContract] private class DataContractClass { public DataContractClass() { PrivatePropertyGetSetDataMemberWithoutName = "private without name"; PrivatePropertyGetSetDataMemberWithName = "private with name"; PrivatePropertyGetSetNoDataMember = "private no data member"; PrivatePropertyGetSetIgnore = "ignore"; } public readonly string ReadOnlyFieldWithoutDataMember = "public readonly without datamember"; [DataMember] public readonly string ReadOnlyFieldDataMemberWithoutName = "public readonly data member without name"; [DataMember(Name = "field_name")] public readonly string ReadOnlyFieldDataMemberWithName = "public readonly data member with name"; #pragma warning disable 0414 [IgnoreDataMember] public readonly string ReadOnlyFieldIgnore = "public readonly ignore"; private readonly string PrivateReadOnlyFieldWithoutDataMember = "private readonly without datamember"; [DataMember] private readonly string PrivateReadOnlyFieldDataMemberWithoutName = "private readonly data member without name"; [DataMember(Name = "private_field_name")] private readonly string PrivateReadOnlyFieldDataMemberWithName = "private readonly data member with name"; [IgnoreDataMember] private readonly string PrivateReadOnlyFieldIgnore = "private readonly ignore"; #pragma warning restore 0414 [DataMember] public string PropertyGetSetDataMemberWithoutName { get; set; } [DataMember] private string PrivatePropertyGetSetDataMemberWithoutName { get; set; } [DataMember(Name = "name")] public string PropertyGetSetDataMemberWithName { get; set; } [DataMember(Name = "private_name")] private string PrivatePropertyGetSetDataMemberWithName { get; set; } public string PropertyGetSetNoDataMember { get; set; } private string PrivatePropertyGetSetNoDataMember { get; set; } [IgnoreDataMember] public string PropertyGetSetIgnore { get; set; } [IgnoreDataMember] private string PrivatePropertyGetSetIgnore { get; set; } [DataMember] public string PropertyGetDataMemberWithoutName { get { return "property get data member without name"; } } [DataMember] private string PrivatePropertyGetDataMemberWithoutName { get { return "property get data member without name"; } } [DataMember(Name = "name_get")] public string PropertyGetDataMemberWithName { get { return "property get data member with name"; } } [DataMember(Name = "private_name_get")] private string PrivatePropertyGetDataMemberWithName { get { return "property get data member with name"; } } public string PropertyGetNoDataMember { get { return "property get no data member"; } } private string PrivatePropertyGetNoDataMember { get { return "private property get no data member"; } } [IgnoreDataMember] public string PropertyGetIgnore { get { return "property get ignore"; } } [IgnoreDataMember] private string PrivatePropertyGetIgnore { get { return "private property get ignore"; } } } private class NonDataContractClass { } private DataContractClass dataContractClass; public JsonDataContractSerializeObjectTests() { this.dataContractClass = new DataContractClass { PropertyGetSetDataMemberWithName = "name", PropertyGetSetDataMemberWithoutName = "nonname", PropertyGetSetNoDataMember = "no_datamember", PropertyGetSetIgnore = "ignored" }; } /* [TestMethod] public void ContainsDataContractAttribute() { Assert.IsTrue(SimpleJson.GetAttribute(this.dataContractClass.GetType(), typeof(DataContractAttribute)) != null); } [TestMethod] public void DoesNotContainDataContractAttribute() { Assert.IsFalse(SimpleJson.GetAttribute(typeof(NonDataContractClass), typeof(DataContractAttribute)) != null); } [TestMethod] public void PropertyGetSetDataMemberWithoutNameTests() { var propertyInfo = typeof(DataContractClass).GetProperty("PropertyGetSetDataMemberWithoutName"); var attr = SimpleJson.GetAttribute(propertyInfo, typeof(DataMemberAttribute)); Assert.IsNotNull(attr); Assert.IsInstanceOf(attr); var dataMemberAttribute = (DataMemberAttribute)attr; Assert.IsNull(dataMemberAttribute.Name); } [TestMethod] public void PropertyGetSetDataMemberWithNameTests() { var propertyInfo = typeof(DataContractClass).GetProperty("PropertyGetSetDataMemberWithName"); var attr = SimpleJson.GetAttribute(propertyInfo, typeof(DataMemberAttribute)); Assert.IsNotNull(attr); Assert.IsInstanceOf(attr); var dataMemberAttribute = (DataMemberAttribute)attr; Assert.AreEqual("name", dataMemberAttribute.Name); } [TestMethod] public void PropertyGetSetNoDataMemberTests() { var propertyInfo = typeof(DataContractClass).GetProperty("PropertyGetSetNoDataMember"); var attr = SimpleJson.GetAttribute(propertyInfo, typeof(DataMemberAttribute)); Assert.IsNull(attr); } */ [TestMethod] public void PublicReadOnlyFieldWithoutDataMemberShouldNotBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsFalse(result.ContainsKey("ReadOnlyFieldWithoutDataMember")); } [TestMethod] public void ReadOnlyFieldDataMemberWithoutNameShouldBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsTrue(result.ContainsKey("ReadOnlyFieldDataMemberWithoutName")); } [TestMethod] public void ReadOnlyFieldDataMemberWithNameShouldBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsTrue(result.ContainsKey("field_name")); } [TestMethod] public void ReadOnlyFieldIgnoreShouldNotBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsFalse(result.ContainsKey("ReadOnlyFieldIgnore")); } [TestMethod] public void PrivateReadOnlyFieldWihtoutDataMemberShouldNotBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsFalse(result.ContainsKey("PrivateReadOnlyFieldWihtoutDataMember")); } [TestMethod] public void PrivateReadOnlyFieldDataMemberWithoutNameShouldBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsTrue(result.ContainsKey("PrivateReadOnlyFieldDataMemberWithoutName")); } [TestMethod] public void PrivateReadOnlyFieldDataMemberWithNameShouldBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsTrue(result.ContainsKey("private_field_name")); } [TestMethod] public void PrivateReadOnlyFieldIgnoreShouldNotBePresent() { var json = SimpleJson.SerializeObject(this.dataContractClass, SimpleJson.DataContractJsonSerializerStrategy); var result = (IDictionary)SimpleJson.DeserializeObject(json); Assert.IsFalse(result.ContainsKey("PrivateReadOnlyFieldIgnore")); } } } ================================================ FILE: src/SimpleJson.Tests/JsonDecodeTypeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System; using System.Collections.Generic; using System.Linq; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class DeserializeObjectTypeTests { // Disable never used warnings for fields - they are actually used in deserialization #pragma warning disable 0169, 0649 private class Person { public string FirstName { get; set; } private string LastName { get; set; } public AddressInfo Address { get; set; } public string[] Langauges; public IEnumerable Hobby; private string[] _nothing; public string[] Nothing { get { return _nothing; } } } private class AddressInfo { public string Country { get; set; } private string City; } #pragma warning restore 0169, 0649 [TestMethod] public void NullStringTests() { var result = SimpleJson.DeserializeObject(null, typeof(Person)); Assert.IsNull(result); } [TestMethod] public void NullStringGenericTests() { var result = SimpleJson.DeserializeObject(null); Assert.IsNull(result); } [TestMethod] public void BooleanTrueTests() { var json = "true"; var result = SimpleJson.DeserializeObject(json); Assert.IsTrue(result); } [TestMethod] public void BooleanFalseTests() { var json = "false"; var result = SimpleJson.DeserializeObject(json); Assert.IsFalse(result); } [TestMethod] public void NullTests() { var json = "null"; var result = SimpleJson.DeserializeObject(json); Assert.IsNull(result); } [TestMethod] public void StringTests() { var json = "\"hello world\""; var result = SimpleJson.DeserializeObject(json); Assert.AreEqual("hello world", result); } [TestMethod] public void DecimalToIntTest() { var json = "10.2"; var result = SimpleJson.DeserializeObject(json); Assert.AreEqual(10, result); } [TestMethod] public void GivenNumberWithoutDecimalTypeIsLong() { var json = "10"; var result = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(result, typeof(long)); #else Assert.IsInstanceOf(result); #endif } [TestMethod] public void GivenNumberWithDecimalTypeIsDouble() { var json = "10.2"; var result = SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsInstanceOfType(result, typeof(double)); #else Assert.IsInstanceOf(result); #endif } [TestMethod] public void GivenGuidAsNull() { var json = "null"; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(default(Guid), guid); } [TestMethod] public void GivenNullableGuidAsNull() { var json = "null"; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(null, guid); } [TestMethod] public void GivenGuidAsEmptyString() { var json = @""""""; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(default(Guid), guid); } [TestMethod] public void GivenNullableGuidAsEmptyString() { var json = @""""""; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(null, guid); } [TestMethod] public void GiveGuidAsStringWithHashAndSmallLetters() { var json = @"""bed7f4ea-1a96-11d2-8f08-00a0c9a6186d"""; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(new Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"), guid); } [TestMethod] public void GiveNullableGuidAsStringWithHashAndSmallLetters() { var json = @"""bed7f4ea-1a96-11d2-8f08-00a0c9a6186d"""; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(new Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"), guid); } [TestMethod] public void GiveGuidAsStringWithHashAndCapitalLetters() { var json = @"""BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"""; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(new Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"), guid); } [TestMethod] public void GivenNullableGuidAsStringWithHashAndCapitalLetters() { var json = @"""BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"""; var guid = SimpleJson.DeserializeObject(json); Assert.AreEqual(new Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"), guid); } [TestMethod] public void ArrayAndListDeserializationTests() { var obj = new { FirstName = "Prabir", LastName = "Shrestha", Address = new { Country = "Nepal", City = "Kathmandu" }, Langauges = new[] { "English", "Nepali" }, Hobby = new[] { "Guitar", "Swimming", "Basketball" }, Nothing = new[] { "nothing" } }; var json = SimpleJson.SerializeObject(obj); var result = SimpleJson.DeserializeObject(json); Assert.AreEqual(obj.FirstName, result.FirstName); Assert.AreEqual(obj.Address.Country, result.Address.Country); Assert.AreEqual(obj.Langauges.Length, result.Langauges.Length); Assert.AreEqual(obj.Langauges[0], result.Langauges[0]); Assert.AreEqual(obj.Langauges[1], result.Langauges[1]); var hobies = result.Hobby.ToList(); Assert.AreEqual(obj.Hobby.Length, hobies.Count); Assert.AreEqual(obj.Hobby[0], hobies[0]); Assert.AreEqual(obj.Hobby[1], hobies[1]); Assert.AreEqual(obj.Hobby[2], hobies[2]); Assert.IsNull(result.Nothing); } [TestMethod] public void ClassArrayTests() { var json = "{\"Name\":\"person1\",\"HobbyArray\":[{\"name\":\"basketball\",\"value\":10},{\"name\":\"football\",\"value\":9}]}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); } [TestMethod] public void ClassListTests() { var json = "{\"Name\":\"person1\",\"HobbyArray\":[{\"name\":\"basketball\",\"value\":10},{\"name\":\"football\",\"value\":9}]}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); } public class HobbyPersonArray { public string Name { get; set; } public Hobbies[] Hobbies { get; set; } } public class HobbyPersonList { public string Name { get; set; } public IList Hobbies { get; set; } } public class Hobbies { public string Name; public int Value; } } } ================================================ FILE: src/SimpleJson.Tests/Package.appxmanifest ================================================  SimleJson.Tests_WinRT Prabir Images\UnitTestStoreLogo.png SimleJson.Tests_WinRT 6.2 6.2 ================================================ FILE: src/SimpleJson.Tests/PocoDeserializerTests/ArrayTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoDeserializerTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif [TestClass] public class ArrayTests { [TestMethod] public void StronglyTypeArrayTests() { string json = "{\"Y\":[\"a\",\"b\"]}"; var result = SimpleJson.SimpleJson.DeserializeObject(json); #if NETFX_CORE Assert.IsNotNull(result); Assert.IsNotNull(result.Y); #else Assert.NotNull(result); Assert.NotNull(result.Y); #endif Assert.AreEqual(2, result.Y.Length); Assert.AreEqual("a", result.Y[0]); Assert.AreEqual("b", result.Y[1]); } class X { public string[] Y { get; set; } public override string ToString() { return SimpleJson.SimpleJson.SerializeObject(this); } } } } ================================================ FILE: src/SimpleJson.Tests/PocoDeserializerTests/DateTimeDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJson.Tests.PocoDeserializerTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif [TestClass] public class DateTimeDeserializeTests { [TestMethod] public void Test() { var json = "\"2004-01-20T05:03:06Z\""; var result = SimpleJson.DeserializeObject(json); Assert.AreEqual(2004, result.Year); Assert.AreEqual(1, result.Month); Assert.AreEqual(20, result.Day); Assert.AreEqual(5, result.Hour); Assert.AreEqual(3, result.Minute); Assert.AreEqual(6, result.Second); Assert.AreEqual(0, result.Millisecond); Assert.AreEqual(DateTimeKind.Utc, result.Kind); } [TestMethod] public void TestWithoutMilisecond() { var json = "{\"Value\":\"2004-01-20T05:03:06Z\"}"; var result = SimpleJson.DeserializeObject(json).Value; Assert.AreEqual(2004, result.Year); Assert.AreEqual(1, result.Month); Assert.AreEqual(20, result.Day); Assert.AreEqual(5, result.Hour); Assert.AreEqual(3, result.Minute); Assert.AreEqual(6, result.Second); Assert.AreEqual(0, result.Millisecond); Assert.AreEqual(DateTimeKind.Utc, result.Kind); } [TestMethod] public void TestWithMilliSecond() { var json = "{\"Value\":\"2004-01-20T05:03:06.012Z\"}"; var result = SimpleJson.DeserializeObject(json).Value; Assert.AreEqual(2004, result.Year); Assert.AreEqual(1, result.Month); Assert.AreEqual(20, result.Day); Assert.AreEqual(5, result.Hour); Assert.AreEqual(3, result.Minute); Assert.AreEqual(6, result.Second); Assert.AreEqual(12, result.Millisecond); Assert.AreEqual(DateTimeKind.Utc, result.Kind); } public class SerializeDateTimeTypeClass { public DateTime Value { get; set; } } } public class DateOffsetTimeDeserializeTests { [TestMethod] public void TestWithMilliSecond() { var json = "{\"Value\":\"2004-01-20T05:03:06.012Z\"}"; var result = SimpleJson.DeserializeObject(json).Value; Assert.AreEqual(2004, result.Year); Assert.AreEqual(1, result.Month); Assert.AreEqual(20, result.Day); Assert.AreEqual(5, result.Hour); Assert.AreEqual(3, result.Minute); Assert.AreEqual(6, result.Second); Assert.AreEqual(12, result.Millisecond); Assert.AreEqual(TimeSpan.Zero, result.Offset); } public class SerializeDateTimeOffsetTypeClass { public DateTimeOffset Value { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoDeserializerTests/DictionaryDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoDeserializerTests { using System.Collections.Generic; #if NUNIT using TestMethod = NUnit.Framework.TestAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; public class DictionaryDeserializeTests { [TestMethod] public void DeserializeToIDictionaryStringString() { string json = @"{""key1"":""value1"",""key2"":""value2""}"; var result = SimpleJson.DeserializeObject>(json); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("value1", result["key1"]); Assert.AreEqual("value2", result["key2"]); } [TestMethod] public void DeserializeToDictionaryStringString() { string json = @"{""key1"":""value1"",""key2"":""value2""}"; var result = SimpleJson.DeserializeObject>(json); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("value1", result["key1"]); Assert.AreEqual("value2", result["key2"]); } [TestMethod] public void DeserializeToIDictionaryStringLong() { string json = @"{""key1"":1,""key2"":5}"; var result = SimpleJson.DeserializeObject>(json); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual(1L, result["key1"]); Assert.AreEqual(5L, result["key2"]); } [TestMethod] public void DeserializeToDictionaryStringLong() { string json = @"{""key1"":1,""key2"":5}"; var result = SimpleJson.DeserializeObject>(json); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual(1L, result["key1"]); Assert.AreEqual(5L, result["key2"]); } [TestMethod] public void NestedDeserializeDictionary() { string json = "{\"regions\": [{\"id\": \"US\",\"value\": {\"1\": \"Alabama\"}}]}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.IsNotNull(result.regions); Assert.AreEqual(1, result.regions.Count); var us = result.regions[0]; Assert.AreEqual("US", us.id); var value = us.value; Assert.AreEqual(1, value.Count); Assert.IsTrue(value.ContainsKey("1")); Assert.AreEqual("Alabama", value["1"]); } class autocomplete_data { public List regions { get; set; } } private class region { public string id { get; set; } public IDictionary value { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoDeserializerTests/ListOfPocoDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoDeserializerTests { using System.Collections.Generic; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif public class ListOfPocoDeserializeTests { [TestMethod] public void CorrectlyDeserializesListOfPoco() { string json = "{\"colleges\":[{\"id\": 16777217,\"value\":\"Harvard\"},{\"id\": 16777218,\"value\":\"Columbia\"}]}"; var result = SimpleJson.SimpleJson.DeserializeObject(json); Assert.IsNotNull(result); Assert.IsNotNull(result.colleges); Assert.AreEqual(2, result.colleges.Count); var harvard = result.colleges[0]; var columbia = result.colleges[1]; Assert.IsNotNull(harvard); Assert.AreEqual(16777217, harvard.id); Assert.AreEqual("Harvard", harvard.value); Assert.IsNotNull(columbia); Assert.AreEqual(16777218, columbia.id); Assert.AreEqual("Columbia", columbia.value); } class autocomplete_data { public List colleges { get; set; } } class college { public long id { get; set; } public string value { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoDeserializerTests/NullableTypeDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJson.Tests.PocoDeserializerTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif [TestClass] public class NullableTypeTests { [TestMethod] public void WithValue() { var json = "4"; var result = SimpleJson.DeserializeObject(json); Assert.AreEqual(4, result.Value); } [TestMethod] public void TestNull() { var json = "null"; var result = SimpleJson.DeserializeObject(json); Assert.IsFalse(result.HasValue); } [TestMethod] public void DateTimeAsNull() { var json = "null"; var result = SimpleJson.DeserializeObject(json); Assert.IsFalse(result.HasValue); } [TestMethod] public void DateTimeWithValue() { var json = "\"2004-01-20T05:03:06Z\""; var result = SimpleJson.DeserializeObject(json).Value; Assert.AreEqual(2004, result.Year); Assert.AreEqual(1, result.Month); Assert.AreEqual(20, result.Day); Assert.AreEqual(5, result.Hour); Assert.AreEqual(3, result.Minute); Assert.AreEqual(6, result.Second); Assert.AreEqual(0, result.Millisecond); Assert.AreEqual(DateTimeKind.Utc, result.Kind); } [TestMethod] public void DateTimeOffsetAsNull() { var json = "null"; var result = SimpleJson.DeserializeObject(json); Assert.IsFalse(result.HasValue); } [TestMethod] public void DateTimeOffsetWithValue() { var json = "\"2004-01-20T05:03:06Z\""; var result = SimpleJson.DeserializeObject(json).Value; Assert.AreEqual(2004, result.Year); Assert.AreEqual(1, result.Month); Assert.AreEqual(20, result.Day); Assert.AreEqual(5, result.Hour); Assert.AreEqual(3, result.Minute); Assert.AreEqual(6, result.Second); Assert.AreEqual(0, result.Millisecond); Assert.AreEqual(TimeSpan.Zero, result.Offset); } [TestMethod] public void NullableTypeClassNullTest() { var json = "{\"Value\":null}"; var result = SimpleJson.DeserializeObject(json); Assert.IsNull(result.Value); } [TestMethod] public void NullableTypeClasssWithvalueTest() { var json = "{\"Value\":4}"; var result = SimpleJson.DeserializeObject(json); Assert.AreEqual(4, result.Value); } public class NullableTypeClass { public int? Value { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoDeserializerTests/PrimitiveDeserializeTest.cs ================================================ using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif namespace SimpleJsonTests.PocoDeserializerTests { [TestClass] public class PrimitiveDeserializeTest { [TestMethod] public void SimpleIntTests() { string json = "{\"Age\":\"12\",\"Name\": \"Simple Json\"}"; var result = SimpleJson.SimpleJson.DeserializeObject(json); Assert.AreEqual(12, result.Age); } [TestMethod] public void SimpleDoubleTests() { string json = "{\"Salary\":\"120.50\",\"Name\": \"Simple Json\"}"; var result = SimpleJson.SimpleJson.DeserializeObject(json); Assert.AreEqual(120.50, result.Salary); } class X { public string Name { get; set; } public int Age { get; set; } public double Salary { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/DateTimeSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJson.Tests.PocoJsonSerializerTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif [TestClass] public class DateTimeSerializeTests { [TestMethod] public void SerializeDateTimeThatHasMilliSecondAsNonZero() { var obj = new SerializeDateTimeTypeClass { Value = new DateTime(2004, 1, 20, 5, 3, 6, 12, DateTimeKind.Utc) }; var json = SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"Value\":\"2004-01-20T05:03:06.012Z\"}", json); } [TestMethod] public void SerializeDateTimeThatHasMilliSecondAsZero() { var obj = new SerializeDateTimeTypeClass { Value = new DateTime(2004, 1, 20, 5, 3, 6, 0, DateTimeKind.Utc) }; var json = SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"Value\":\"2004-01-20T05:03:06Z\"}", json); } public class SerializeDateTimeTypeClass { public DateTime Value { get; set; } } } [TestClass] public class DateTimeOffsetSerializeTests { [TestMethod] public void SerializeDateTimeOffsetThatHasMilliSecondAsNonZero() { var obj = new SerializeDateTimeOffsetTypeClass { Value = new DateTimeOffset(2004, 1, 20, 5, 3, 6, 12, TimeSpan.Zero) }; var json = SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"Value\":\"2004-01-20T05:03:06.012Z\"}", json); } public class SerializeDateTimeOffsetTypeClass { public DateTimeOffset Value { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/NullableSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif [TestClass] public class NullableSerializeTests { [TestMethod] public void Test() { DateTime? obj = null; var json = SimpleJson.SimpleJson.SerializeObject(obj); Assert.AreEqual("null", json); } [TestMethod] public void TestWithValue() { DateTime? obj = new DateTime(2004, 1, 20, 5, 3, 6, 12, DateTimeKind.Utc); var json = SimpleJson.SimpleJson.SerializeObject(obj); Assert.AreEqual("\"2004-01-20T05:03:06.012Z\"", json); } [TestMethod] public void TestNullDateTimeOffset() { DateTimeOffset? obj = null; var json = SimpleJson.SimpleJson.SerializeObject(obj); Assert.AreEqual("null", json); } [TestMethod] public void TestDateTimeOffsetWithValue() { DateTimeOffset? obj = new DateTimeOffset(2004, 1, 20, 5, 3, 6, 12, TimeSpan.Zero); var json = SimpleJson.SimpleJson.SerializeObject(obj); Assert.AreEqual("\"2004-01-20T05:03:06.012Z\"", json); } [TestMethod] public void SerializeNullableTypeThatIsNotNull() { var obj = new NullableTypeClass(); obj.Value = null; var json = SimpleJson.SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"Value\":null}", json); } [TestMethod] public void SerializeNullableTypeThatIsNull() { var obj = new NullableTypeClass(); obj.Value = 4; var json = SimpleJson.SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"Value\":4}", json); } public class NullableTypeClass { public int? Value { get; set; } } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateFieldsDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateFieldsDeserializeTests { [TestMethod] public void DeserializesNullCorrectly() { var json = "null"; var result = SimpleJson.DeserializeObject(json, typeof(DataContractPrivateFields), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNull(result); } [TestMethod] public void DeserializesEmptyObjectCorrectly() { var json = "{}"; var result = SimpleJson.DeserializeObject(json, typeof(DataContractPrivateFields), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateFieldsSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateFieldsSerializeTests { private DataContractPrivateFields _dataContractPrivateFields; public PrivateFieldsSerializeTests() { _dataContractPrivateFields = new DataContractPrivateFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateFields, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateGetterSettersDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateGetterSettersDeserializeTests { [TestMethod] public void SerializesNullCorrectly() { var json = "null"; var result = SimpleJson.DeserializeObject(json, typeof(DataContractPrivateGetterSetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNull(result); } [TestMethod] public void SerializesEmptyObjectCorrectly() { var json = "{}"; var result = SimpleJson.DeserializeObject(json, typeof(DataContractPrivateGetterSetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateGetterSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateGetterSettersSerializeTests { private DataContractPrivateGetterSetters _dataContractPrivateGetterSetters; public PrivateGetterSettersSerializeTests() { _dataContractPrivateGetterSetters = new DataContractPrivateGetterSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateGetterSetters, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateGettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateGettersSerializeTests { private DataContractPrivateGetters _dataContractPrivateGetters; public PrivateGettersSerializeTests() { _dataContractPrivateGetters = new DataContractPrivateGetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateGetters, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateReadonlySerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateReadonlySerializeTests { private DataContractPrivateReadOnlyFields _dataContractPrivateReadOnlyFields; public PrivateReadonlySerializeTests() { _dataContractPrivateReadOnlyFields = new DataContractPrivateReadOnlyFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateReadOnlyFields, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PrivateSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PrivateSettersSerializeTests { private DataContractPrivateSetters _dataContractPrivateSetters; public PrivateSettersSerializeTests() { _dataContractPrivateSetters = new DataContractPrivateSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPrivateSetters, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicFieldsDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicFieldsDeserializeTests { [TestMethod] public void DeserializesNullObjectCorrectly() { var json = "null"; var result = (DataContractPublicFields)SimpleJson.DeserializeObject(json, typeof(DataContractPublicFields), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNull(result); } [TestMethod] public void DeserializesEmptyObjectCorrectly() { var json = "{}"; var obj = new DataContractPublicFields(); var result = (DataContractPublicFields)SimpleJson.DeserializeObject(json, typeof(DataContractPublicFields), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual(obj.NoDataMember, result.NoDataMember); Assert.AreEqual(obj.IgnoreDataMember, result.IgnoreDataMember); Assert.AreEqual(obj.DatMemberWithName, result.DatMemberWithName); Assert.AreEqual(obj.DataMemberWithoutName, result.DataMemberWithoutName); } [TestMethod] public void DeserializesCorrectly() { var json = "{\"DataMemberWithoutName\":\"1\",\"DatMemberWithName\":\"2\",\"IgnoreDataMember\":\"3\",\"NoDataMember\":\"4\"}"; var result = (DataContractPublicFields)SimpleJson.DeserializeObject(json, typeof(DataContractPublicFields), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual("1", result.DataMemberWithoutName); Assert.AreEqual("2", result.DatMemberWithName); Assert.AreEqual("3", result.IgnoreDataMember); Assert.AreEqual("4", result.NoDataMember); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicFieldsSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicFieldsSerializeTests { private DataContractPublicFields _dataContractPublicFields; public PublicFieldsSerializeTests() { _dataContractPublicFields = new DataContractPublicFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicFields, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"DatMemberWithName\":\"dmnv\",\"IgnoreDataMember\":\"idm\",\"NoDataMember\":\"ndm\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicGetterDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicGetterDeserializeTests { [TestMethod] public void DeserializesNullObjectCorrectly() { var json = "null"; var result = (DataContractPublicFields)SimpleJson.DeserializeObject(json, typeof(DataContractPublicGetterSetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNull(result); } [TestMethod] public void DeserializesEmptyObjectCorrectly() { var json = "{}"; var obj = new DataContractPublicGetters(); var result = (DataContractPublicGetters)SimpleJson.DeserializeObject(json, typeof(DataContractPublicGetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual(obj.DataMemberWithoutName, result.DataMemberWithoutName); Assert.AreEqual(obj.DatMemberWithName, result.DatMemberWithName); Assert.AreEqual(obj.IgnoreDataMember, result.IgnoreDataMember); Assert.AreEqual(obj.NoDataMember, result.NoDataMember); } [TestMethod] public void DeserializesCorrectly() { var json = "{\"DataMemberWithoutName\":\"1\",\"DatMemberWithName\":\"2\",\"IgnoreDataMember\":\"3\",\"NoDataMember\":\"4\"}"; var obj = new DataContractPublicGetters(); var result = (DataContractPublicGetters)SimpleJson.DeserializeObject(json, typeof(DataContractPublicGetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual(obj.DataMemberWithoutName, result.DataMemberWithoutName); Assert.AreEqual(obj.DatMemberWithName, result.DatMemberWithName); Assert.AreEqual(obj.IgnoreDataMember, result.IgnoreDataMember); Assert.AreEqual(obj.NoDataMember, result.NoDataMember); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicGetterSetterDeserializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicGetterSetterDeserializeTests { [TestMethod] public void DeserializesNullObjectCorrectly() { var json = "null"; var result = (DataContractPublicFields)SimpleJson.DeserializeObject(json, typeof(DataContractPublicGetterSetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNull(result); } [TestMethod] public void DeserializesEmptyObjectCorrectly() { var json = "{}"; var obj = new DataContractPublicGetterSetters(); var result = (DataContractPublicGetterSetters)SimpleJson.DeserializeObject(json, typeof(DataContractPublicGetterSetters), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual(obj.DataMemberWithoutName, result.DataMemberWithoutName); Assert.AreEqual(obj.DatMemberWithName, result.DatMemberWithName); Assert.AreEqual(obj.IgnoreDataMember, result.IgnoreDataMember); Assert.AreEqual(obj.NoDataMember, result.NoDataMember); } [TestMethod] public void DeserializesCorrectly() { var json = "{\"DataMemberWithoutName\":\"1\",\"DatMemberWithName\":\"2\",\"IgnoreDataMember\":\"3\",\"NoDataMember\":\"4\"}"; var result = (DataContractPublicFields)SimpleJson.DeserializeObject(json, typeof(DataContractPublicFields), SimpleJson.PocoJsonSerializerStrategy); Assert.IsNotNull(result); Assert.AreEqual("1", result.DataMemberWithoutName); Assert.AreEqual("2", result.DatMemberWithName); Assert.AreEqual("3", result.IgnoreDataMember); Assert.AreEqual("4", result.NoDataMember); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicGetterSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicGetterSettersSerializeTests { private DataContractPublicGetterSetters _dataContractPublicGetterSetters; public PublicGetterSettersSerializeTests() { _dataContractPublicGetterSetters = new DataContractPublicGetterSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicGetterSetters, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"DatMemberWithName\":\"dmnv\",\"IgnoreDataMember\":\"idm\",\"NoDataMember\":\"ndm\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicGettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicGettersSerializeTests { private DataContractPublicGetters _contractPublicGetters; public PublicGettersSerializeTests() { _contractPublicGetters = new DataContractPublicGetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_contractPublicGetters, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"DatMemberWithName\":\"dmnv\",\"IgnoreDataMember\":\"idm\",\"NoDataMember\":\"ndm\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicReadonlySerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicReadonlySerializeTests { private DataContractPublicReadOnlyFields _dataContractPublicReadOnlyFields; public PublicReadonlySerializeTests() { _dataContractPublicReadOnlyFields = new DataContractPublicReadOnlyFields(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicReadOnlyFields, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{\"DataMemberWithoutName\":\"dmv\",\"DatMemberWithName\":\"dmnv\",\"IgnoreDataMember\":\"idm\",\"NoDataMember\":\"ndm\"}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/PublicSettersSerializeTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; using SimpleJsonTests.DataContractTests; [TestClass] public class PublicSettersSerializeTests { private DataContractPublicSetters _dataContractPublicSetters; public PublicSettersSerializeTests() { _dataContractPublicSetters = new DataContractPublicSetters(); } [TestMethod] public void SerializesCorrectly() { var result = SimpleJson.SerializeObject(_dataContractPublicSetters, SimpleJson.PocoJsonSerializerStrategy); Assert.AreEqual("{}", result); } } } ================================================ FILE: src/SimpleJson.Tests/PocoJsonSerializerTests/ToStringTests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests.PocoJsonSerializerTests { #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif [TestClass] public class ToStringTests { [TestMethod] public void ToStringCallingSerializeObjectOnItself() { var x = new X { Y = "z" }; var json = SimpleJson.SimpleJson.SerializeObject(x); Assert.AreEqual("{\"Y\":\"z\"}", json); } class X { public string Y { get; set; } public override string ToString() { return SimpleJson.SimpleJson.SerializeObject(this, SimpleJson.SimpleJson.PocoJsonSerializerStrategy); } } } } ================================================ FILE: src/SimpleJson.Tests/Properties/AssemblyInfo.cs ================================================ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("SimpleJson.Tests")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("The Outercurve Foundation")] [assembly: AssemblyProduct("SimpleJson.Tests")] [assembly: AssemblyCopyright("Copyright © The Outercurve Foundation 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("d2eb41dc-3e13-4008-8e0b-71cc9671d3b7")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] ================================================ FILE: src/SimpleJson.Tests/SerializeObject.KnownNonPrimitive.Tests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class SerializeObject_KnownNonPrimitive_Tests { [TestMethod] public void GuidSerialization() { Guid guid = new Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D"); var json = SimpleJson.SerializeObject(guid); Assert.AreEqual(@"""bed7f4ea-1a96-11d2-8f08-00a0c9a6186d""", json); } [TestMethod] public void EnumSerialization() { string json = SimpleJson.SerializeObject(StringComparison.CurrentCultureIgnoreCase); Assert.AreEqual("1", json); } [TestMethod] public void UriSerialization() { string json = SimpleJson.SerializeObject(new Uri("http://simplejson.codeplex.com/")); Assert.AreEqual("\"http://simplejson.codeplex.com/\"", json); } } } ================================================ FILE: src/SimpleJson.Tests/SerializeObject.Primitive.Tests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System.Collections.Generic; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class SerializeObject_Primitive_Tests { [TestMethod] public void ObjectSerialization() { object value; value = 1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = 1.1; Assert.AreEqual("1.1", SimpleJson.SerializeObject(value)); value = 1.1m; Assert.AreEqual("1.1", SimpleJson.SerializeObject(value)); //value = (float)1.1; //Assert.AreEqual("1.1", SimpleJson.JsonEncode(value)); value = (short)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = (long)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = (byte)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = (uint)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = (ushort)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = (sbyte)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = (ulong)1; Assert.AreEqual("1", SimpleJson.SerializeObject(value)); value = null; Assert.AreEqual("null", SimpleJson.SerializeObject(value)); //value = DBNull.Value; //Assert.AreEqual("null", SimpleJson.JsonEncode(value)); value = "I am a string"; Assert.AreEqual(@"""I am a string""", SimpleJson.SerializeObject(value)); value = true; Assert.AreEqual("true", SimpleJson.SerializeObject(value)); value = false; Assert.AreEqual("false", SimpleJson.SerializeObject(value)); //value = 'c'; //Assert.AreEqual(@"""c""", SimpleJson.JsonEncode(value)); } [TestMethod] public void StringSerialization() { string str = "I am a string"; Assert.AreEqual(@"""I am a string""", SimpleJson.SerializeObject(str)); } [TestMethod] public void StringEscpaingSerialization() { string v = @"It's a good day ""sunshine"""; string json = SimpleJson.SerializeObject(v); Assert.AreEqual(@"""It's a good day\r\n\""sunshine\""""", json); } [TestMethod] #if NETFX_CORE [Ignore] #else [Ignore("not part of the json standard.")] #endif public void CharSerialization() { Assert.AreEqual(@"""c""", SimpleJson.SerializeObject('c')); } [TestMethod] public void BoolTrueSerialization() { Assert.AreEqual("true", SimpleJson.SerializeObject(true)); } [TestMethod] public void BoolFalseSerialization() { Assert.AreEqual("false", SimpleJson.SerializeObject(false)); } [TestMethod] public void NullSerialization() { Assert.AreEqual("null", SimpleJson.SerializeObject(null)); } #if !NETFX_CORE [TestMethod] [Ignore("uncomment if(Convert.IsDBNull(input)) in PocoJsonSerializerStrategy.TrySerializeKnownTypes. disabled to improve performance.")] public void DbNullSerialization() { Assert.AreEqual("null", SimpleJson.SerializeObject(System.DBNull.Value)); } #endif [TestMethod] public void Int16Serialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((short)1)); } [TestMethod] public void UnsingedInt16Serialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((ushort)1)); } [TestMethod] public void Int64Serialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((long)1)); } [TestMethod] public void UnsingedInt64Serialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((ulong)1)); } [TestMethod] public void ByteSerialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((byte)1)); } [TestMethod] public void SignedByteSerialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((sbyte)1)); } [TestMethod] public void Int32Serialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((int)1)); } [TestMethod] public void UnsingedInt32Serialization() { Assert.AreEqual("1", SimpleJson.SerializeObject((uint)1)); } [TestMethod] public void DoubleSerialization() { Assert.AreEqual("1.1", SimpleJson.SerializeObject(1.1)); } [TestMethod] public void DecimalSerialization() { Assert.AreEqual("1.1", SimpleJson.SerializeObject(1.1m)); Assert.AreEqual("1.11", SimpleJson.SerializeObject(1.11m)); Assert.AreEqual("1.111", SimpleJson.SerializeObject(1.111m)); Assert.AreEqual("1.1111", SimpleJson.SerializeObject(1.1111m)); Assert.AreEqual("1.11111", SimpleJson.SerializeObject(1.11111m)); Assert.AreEqual("1.111111", SimpleJson.SerializeObject(1.111111m)); //Assert.AreEqual("1.0", SimpleJson.JsonEncode(1.0m)); //Assert.AreEqual("-1.0", SimpleJson.JsonEncode(-1.0m)); //Assert.AreEqual("-1.0", SimpleJson.JsonEncode(-1m)); //Assert.AreEqual("1.0", SimpleJson.JsonEncode(1m)); Assert.AreEqual("1.01", SimpleJson.SerializeObject(1.01m)); Assert.AreEqual("1.001", SimpleJson.SerializeObject(1.001m)); //Assert.AreEqual("79228162514264337593543950335.0", SimpleJson.JsonEncode(decimal.MaxValue)); //Assert.AreEqual("-79228162514264337593543950335.0", SimpleJson.JsonEncode(decimal.MinValue)); } [TestMethod] public void FloatSerialization() { Assert.AreEqual("1.1", SimpleJson.SerializeObject(1.1)); Assert.AreEqual("1.11", SimpleJson.SerializeObject(1.11)); Assert.AreEqual("1.111", SimpleJson.SerializeObject(1.111)); Assert.AreEqual("1.1111", SimpleJson.SerializeObject(1.1111)); Assert.AreEqual("1.11111", SimpleJson.SerializeObject(1.11111)); Assert.AreEqual("1.111111", SimpleJson.SerializeObject(1.111111)); //Assert.AreEqual("1.0", SimpleJson.JsonEncode(1.0)); //Assert.AreEqual("1.0", SimpleJson.JsonEncode(1d)); //Assert.AreEqual("-1.0", SimpleJson.JsonEncode(-1d)); Assert.AreEqual("1.01", SimpleJson.SerializeObject(1.01)); Assert.AreEqual("1.001", SimpleJson.SerializeObject(1.001)); //Assert.AreEqual(JsonConvert.PositiveInfinity, SimpleJson.JsonEncode(double.PositiveInfinity)); //Assert.AreEqual(JsonConvert.NegativeInfinity, SimpleJson.JsonEncode(double.NegativeInfinity)); //Assert.AreEqual(JsonConvert.NaN, SimpleJson.JsonEncode(double.NaN)); } [TestMethod] public void EmptyObjectSerialization() { Assert.AreEqual("{}", SimpleJson.SerializeObject(new object())); } [TestMethod] public void CanParseWithUnicode() { var dog = new { Name = "Ăbbey" }; var serialized = SimpleJson.SerializeObject(dog); var deserialized = (IDictionary)SimpleJson.DeserializeObject(serialized); Assert.AreEqual(dog.Name, deserialized["Name"]); } [TestMethod] public void CanSerializeArrays() { const string expected = "[1,2,3]"; var data = new[] { 1, 2, 3 }; var serialized = SimpleJson.SerializeObject(data); Assert.AreEqual(expected, serialized); } [TestMethod] public void CanSerializeEmptyArray() { const string expected = "[]"; var data = new int[0]; var serialized = SimpleJson.SerializeObject(data); Assert.AreEqual(expected, serialized); } [TestMethod] public void CanSerializeNullArray() { const string expected = "null"; int[] data = null; var serialized = SimpleJson.SerializeObject(data); Assert.AreEqual(expected, serialized); } [TestMethod] public void CanSerializeList() { const string expected = "[\"a\",\"b\",\"c\"]"; var data = new List { "a", "b", "c" }; var serialized = SimpleJson.SerializeObject(data); Assert.AreEqual(expected, serialized); } [TestMethod] [Ignore] public void CanIgnoreSolidusInStringLiterals() { const string expected = @"What is the phone #/digits?"; var serialized = SimpleJson.SerializeObject( new { Value = @"What is the phone #\/digits?" }); var actual = (IDictionary)SimpleJson.DeserializeObject(serialized); Assert.AreEqual(expected, actual["Value"]); } [TestMethod] public void SerializeUnicodeTests() { var o = SimpleJson.SerializeObject("न"); Assert.AreEqual("\"न\"", o); } [TestMethod] public void SerializeDictionaryStringObjectTests() { Dictionary parameters = new Dictionary(); parameters["caption"] = string.Empty; parameters["description"] = "hello world"; parameters["link"] = "http://google.com"; var result = SimpleJson.SerializeObject(parameters); Assert.AreEqual("{\"caption\":\"\",\"description\":\"hello world\",\"link\":\"http://google.com\"}", result); } [TestMethod] public void SerializeDictionaryStringStringTests() { Dictionary parameters = new Dictionary(); parameters["caption"] = string.Empty; parameters["description"] = "hello world"; parameters["link"] = "http://google.com"; var result = SimpleJson.SerializeObject(parameters); Assert.AreEqual("{\"caption\":\"\",\"description\":\"hello world\",\"link\":\"http://google.com\"}", result); } [TestMethod] public void SerializeSurrogatePair() { string str = "𩸽 is Arabesque greenling(fish) in japanese"; string json = SimpleJson.SerializeObject(str); Assert.AreEqual("\"𩸽 is Arabesque greenling(fish) in japanese\"", json); } [TestMethod] public void SerializeDoubleQuotesCorrectly() { var obj = new { message = "Hi \"Prabir\"" }; string json = SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"message\":\"Hi \\\"Prabir\\\"\"}", json); } [TestMethod] public void SerializeBigNumberCorrectly() { string json = SimpleJson.SerializeObject(new { object_id = 10150098461530576 }); Assert.AreEqual("{\"object_id\":10150098461530576}", json); } [TestMethod] public void SerializeNullableTypeThatIsNotNull() { var obj = new Dictionary(); int? value = 3; obj["value"] = value; string json = SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"value\":3}", json); } [TestMethod] public void SerializeNullableTypeThatIsNull() { var obj = new Dictionary(); int? value = null; obj["value"] = value; string json = SimpleJson.SerializeObject(obj); Assert.AreEqual("{\"value\":null}", json); } } } ================================================ FILE: src/SimpleJson.Tests/SerializeObject.UnknownNonPrimitive.Tests.cs ================================================ //----------------------------------------------------------------------- // // Copyright (c) 2011, The Outercurve Foundation. // // Licensed under the MIT License (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.opensource.org/licenses/mit-license.php // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me) // https://github.com/facebook-csharp-sdk/simple-json //----------------------------------------------------------------------- namespace SimpleJsonTests { using System; #if NUNIT using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framework.TestAttribute; using TestCleanup = NUnit.Framework.TearDownAttribute; using TestInitialize = NUnit.Framework.SetUpAttribute; using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; using NUnit.Framework; #else #if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; #else using Microsoft.VisualStudio.TestTools.UnitTesting; #endif #endif using SimpleJson; [TestClass] public class SerializeObject_UnknownNonPrimitive_Tests { private class Dog { public string Name { get; set; } } public class ObjProp { public string PropTypeKnown { get; set; } public object PropTypeUnknown { get; set; } } [TestMethod] public void CanSerializeClassInstanceExample() { const string expected = @"{""Name"":""spot""}"; var dog = new Dog { Name = "spot" }; var json = SimpleJson.SerializeObject(dog); Assert.AreEqual(expected, json); } [TestMethod] public void CanSerializeAnonymousObject() { const string expected = @"{""name"":""spot""}"; var instance = new { name = "spot" }; var json = SimpleJson.SerializeObject(instance); Assert.AreEqual(expected, json); } [TestMethod] public void CanSerializeAnonymousObjectWithNumbers() { // todo: make json encode smaller by removing spaces after , const string expected = @"{""quantity"":8902,""cost"":45.33,""value"":-0.01063}"; var instance = new { quantity = 8902, cost = 45.33, value = -1.063E-02 }; var json = SimpleJson.SerializeObject(instance); Assert.AreEqual(expected, json); } [TestMethod] public void CanSerializeWithAnonymousTypes() { const string expected = @"{""array"":{""quantity"":8902,""cost"":45.33,""value"":-0.01063}}"; var instance = new { array = new { quantity = 8902, cost = 45.33, value = -1.063E-02 } }; var json = SimpleJson.SerializeObject(instance); Assert.AreEqual(expected, json); } [TestMethod] public void CanSerializeWithDatesThatHasMilliSecondAsNonZero() { var instance = new { now = new DateTime(2004, 1, 20, 5, 3, 6, 12, DateTimeKind.Utc) }; var json = SimpleJson.SerializeObject(instance); Assert.IsNotNull(json); Assert.AreEqual("{\"now\":\"2004-01-20T05:03:06.012Z\"}", json); } [TestMethod] public void CanSerializeWithDatesThatHasMilliSecondAsZero() { var instance = new { now = new DateTime(2004, 1, 20, 5, 3, 6, 0, DateTimeKind.Utc) }; var json = SimpleJson.SerializeObject(instance); Assert.IsNotNull(json); Assert.AreEqual("{\"now\":\"2004-01-20T05:03:06Z\"}", json); } [TestMethod] public void CanSerializeUnknownProperty() { var instance = new ObjProp { PropTypeKnown = "str", PropTypeUnknown = new { unknown = "property" } }; var json = SimpleJson.SerializeObject(instance); Assert.AreEqual("{\"PropTypeKnown\":\"str\",\"PropTypeUnknown\":{\"unknown\":\"property\"}}", json); } [TestMethod] public void CanSerializeUnknownPropertyUsingNamingConvention() { var instance = new ObjProp { PropTypeKnown = "str", PropTypeUnknown = new { unknown = "property" } }; var json = SimpleJson.SerializeObject(instance, new MyJsonSerializerStrategy()); Assert.AreEqual("{\"prop_type_known\":\"str\",\"prop_type_unknown\":{\"unknown\":\"property\"}}", json); } [TestMethod] public void CanRoundTrip() { var instance = new ObjProp { PropTypeKnown = "str", PropTypeUnknown = new { unknown = "property" } }; var json = SimpleJson.SerializeObject(instance, new MyJsonSerializerStrategy()); Assert.AreEqual("{\"prop_type_known\":\"str\",\"prop_type_unknown\":{\"unknown\":\"property\"}}", json); var result = SimpleJson.DeserializeObject(json, new MyJsonSerializerStrategy()); Assert.AreEqual("str", result.PropTypeKnown); } private class MyJsonSerializerStrategy : PocoJsonSerializerStrategy { protected override string MapClrMemberNameToJsonFieldName(string clrPropertyName) { return clrPropertyName == "PropTypeKnown" ? "prop_type_known" : clrPropertyName == "PropTypeUnknown" ? "prop_type_unknown" : clrPropertyName; } } } } ================================================ FILE: src/SimpleJson.Tests/SimleJson.Tests-WindowsStore.csproj ================================================  Debug AnyCPU 8.0.30703 2.0 {257EBC11-3373-49B2-AD05-2054E8761961} Library Properties SimleJson.Tests SimleJson.Tests en-US 512 {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} SimleJson.Tests-WinRT_TemporaryKey.pfx A5C53E8400B3755C7FF036D15172CEB355A398AB true full false bin\Debug\ DEBUG;TRACE;NETFX_CORE prompt 4 pdbonly true bin\Release\ TRACE;NETFX_CORE prompt 4 true bin\ARM\Debug\ DEBUG;TRACE;NETFX_CORE ;2008 full ARM false prompt ExpressRules.ruleset true bin\ARM\Release\ TRACE;NETFX_CORE true ;2008 pdbonly ARM false prompt ExpressRules.ruleset true true bin\x64\Debug\ DEBUG;TRACE;NETFX_CORE ;2008 full x64 false prompt ExpressRules.ruleset true bin\x64\Release\ TRACE;NETFX_CORE true ;2008 pdbonly x64 false prompt ExpressRules.ruleset true true bin\x86\Debug\ DEBUG;TRACE;NETFX_CORE ;2008 full x86 false prompt ExpressRules.ruleset true bin\x86\Release\ TRACE;NETFX_CORE true ;2008 pdbonly x86 false prompt ExpressRules.ruleset true True Designer PreserveNewest PreserveNewest PreserveNewest PreserveNewest {95427de1-88b5-4679-9d96-b7ac4739a7fa} SimpleJson-WindowsStore 11.0 ================================================ FILE: src/SimpleJson.Tests/SimpleJson.Tests.csproj ================================================  Debug AnyCPU 8.0.30703 2.0 {A8993045-3923-488D-BCD5-F7C1F81ACDED} Library Properties SimpleJson.Tests SimpleJson.Tests v4.0 512 true full false ..\..\bin\Tests\Net40\Debug\ TRACE;DEBUG;NUNIT;SIMPLE_JSON_DATACONTRACT; prompt 4 x86 pdbonly true ..\..\bin\Tests\Net40\Release\ TRACE;NUNIT;SIMPLE_JSON_DATACONTRACT prompt 4 x86 False ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll False ..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll False ..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll {8264c25c-4195-4d37-b848-de6a5c4f27cc} SimpleJson-Portable ================================================ FILE: src/SimpleJson.Tests/packages.config ================================================  ================================================ FILE: src/SimpleJson.nuspec ================================================ SimpleJson $version$ Jim Zimmerman, Nathan Totten, Prabir Shrestha Jim Zimmerman, Nathan Totten, Prabir Shrestha https://raw.github.com/facebook-csharp-sdk/simple-json/master/LICENSE.txt https://raw.github.com/facebook-csharp-sdk/simple-json false Super lightweight Json library for .NET 2.0+/SL4+/WP7/WindowsStore Apps/Portable Class Libraries along with dynamic and DataContract support en-US json ================================================ FILE: src/SimpleJson.sln ================================================  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.20827.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{AEDAD4B4-9F2C-4992-8CD6-A43DFDFF7172}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A6BE2C6-039D-408B-85D8-D130BD01D6A4}" ProjectSection(SolutionItems) = preProject ..\rakefile.rb = ..\rakefile.rb ..\README.md = ..\README.md simplejson.script.ps1 = simplejson.script.ps1 EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Net40", "SimpleJson\SimpleJson-Net40.csproj", "{4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Net20", "SimpleJson\SimpleJson-Net20.csproj", "{02523326-C4CA-45B1-9C1B-2438D218A5C0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Net35", "SimpleJson\SimpleJson-Net35.csproj", "{5033CD0A-483B-4E41-87A2-D0F65905B5D3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-SL4", "SimpleJson\SimpleJson-SL4.csproj", "{4A93FDBA-28DD-4737-B0DF-72CF0C42D962}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-WP7", "SimpleJson\SimpleJson-WP7.csproj", "{A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson.Tests", "SimpleJson.Tests\SimpleJson.Tests.csproj", "{A8993045-3923-488D-BCD5-F7C1F81ACDED}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonViewer", "JsonViewer\JsonViewer.csproj", "{47BE12D4-634F-4ABC-BFEE-81DE3D40A639}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-SL5", "SimpleJson\SimpleJson-SL5.csproj", "{F918711A-6A76-488E-8990-0F0B73E1F532}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Portable", "SimpleJson\SimpleJson-Portable.csproj", "{8264C25C-4195-4D37-B848-DE6A5C4F27CC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Portable-NoLinqExpression", "SimpleJson\SimpleJson-Portable-NoLinqExpression.csproj", "{EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-WindowsStore", "SimpleJson\SimpleJson-WindowsStore.csproj", "{95427DE1-88B5-4679-9D96-B7AC4739A7FA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Net45", "SimpleJson\SimpleJson-Net45.csproj", "{19F83E93-3679-4A93-8E3B-707050A96E85}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-WP71", "SimpleJson\SimpleJson-WP71.csproj", "{954977A1-6134-4F60-A0B7-FF041828E267}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimleJson.Tests-WindowsStore", "SimpleJson.Tests\SimleJson.Tests-WindowsStore.csproj", "{257EBC11-3373-49B2-AD05-2054E8761961}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleJson-Portable-WP8WinStoreNet45", "SimpleJson\SimpleJson-Portable-WP8WinStoreNet45.csproj", "{EC52A094-1CDB-4F5D-8A8A-86F501FC601C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|ARM = Debug|ARM Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|ARM = Release|ARM Release|Mixed Platforms = Release|Mixed Platforms Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|ARM.ActiveCfg = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|x64.ActiveCfg = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Debug|x86.ActiveCfg = Debug|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|Any CPU.Build.0 = Release|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|ARM.ActiveCfg = Release|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|Mixed Platforms.Build.0 = Release|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|x64.ActiveCfg = Release|Any CPU {4EE1BC6A-D96B-4BD6-A6F3-2E2135AA9B99}.Release|x86.ActiveCfg = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|ARM.ActiveCfg = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|x64.ActiveCfg = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Debug|x86.ActiveCfg = Debug|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|Any CPU.ActiveCfg = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|Any CPU.Build.0 = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|ARM.ActiveCfg = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|Mixed Platforms.Build.0 = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|x64.ActiveCfg = Release|Any CPU {02523326-C4CA-45B1-9C1B-2438D218A5C0}.Release|x86.ActiveCfg = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|ARM.ActiveCfg = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|x64.ActiveCfg = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Debug|x86.ActiveCfg = Debug|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|Any CPU.Build.0 = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|ARM.ActiveCfg = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|x64.ActiveCfg = Release|Any CPU {5033CD0A-483B-4E41-87A2-D0F65905B5D3}.Release|x86.ActiveCfg = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|Any CPU.Build.0 = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|ARM.ActiveCfg = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|x64.ActiveCfg = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Debug|x86.ActiveCfg = Debug|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|Any CPU.ActiveCfg = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|Any CPU.Build.0 = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|ARM.ActiveCfg = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|Mixed Platforms.Build.0 = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|x64.ActiveCfg = Release|Any CPU {4A93FDBA-28DD-4737-B0DF-72CF0C42D962}.Release|x86.ActiveCfg = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|ARM.ActiveCfg = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|x64.ActiveCfg = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Debug|x86.ActiveCfg = Debug|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|Any CPU.Build.0 = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|ARM.ActiveCfg = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|Mixed Platforms.Build.0 = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|x64.ActiveCfg = Release|Any CPU {A1116A6E-B599-4AB0-87ED-ED0F3452A7F6}.Release|x86.ActiveCfg = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|ARM.ActiveCfg = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|x64.ActiveCfg = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Debug|x86.ActiveCfg = Debug|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|Any CPU.Build.0 = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|ARM.ActiveCfg = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|Mixed Platforms.Build.0 = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|x64.ActiveCfg = Release|Any CPU {A8993045-3923-488D-BCD5-F7C1F81ACDED}.Release|x86.ActiveCfg = Release|Any CPU {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|Any CPU.ActiveCfg = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|ARM.ActiveCfg = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|Mixed Platforms.Build.0 = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|x64.ActiveCfg = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|x86.ActiveCfg = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Debug|x86.Build.0 = Debug|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|Any CPU.ActiveCfg = Release|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|ARM.ActiveCfg = Release|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|Mixed Platforms.ActiveCfg = Release|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|Mixed Platforms.Build.0 = Release|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|x64.ActiveCfg = Release|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|x86.ActiveCfg = Release|x86 {47BE12D4-634F-4ABC-BFEE-81DE3D40A639}.Release|x86.Build.0 = Release|x86 {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|Any CPU.Build.0 = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|ARM.ActiveCfg = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|x64.ActiveCfg = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Debug|x86.ActiveCfg = Debug|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|Any CPU.ActiveCfg = Release|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|Any CPU.Build.0 = Release|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|ARM.ActiveCfg = Release|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|Mixed Platforms.Build.0 = Release|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|x64.ActiveCfg = Release|Any CPU {F918711A-6A76-488E-8990-0F0B73E1F532}.Release|x86.ActiveCfg = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|ARM.ActiveCfg = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|x64.ActiveCfg = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Debug|x86.ActiveCfg = Debug|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|Any CPU.Build.0 = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|ARM.ActiveCfg = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|x64.ActiveCfg = Release|Any CPU {8264C25C-4195-4D37-B848-DE6A5C4F27CC}.Release|x86.ActiveCfg = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|ARM.ActiveCfg = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|x64.ActiveCfg = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Debug|x86.ActiveCfg = Debug|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|Any CPU.Build.0 = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|ARM.ActiveCfg = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|Mixed Platforms.Build.0 = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|x64.ActiveCfg = Release|Any CPU {EC4EAFB1-A0A3-4C7B-8B38-CFEED0D6FC0A}.Release|x86.ActiveCfg = Release|Any CPU {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|ARM.ActiveCfg = Debug|ARM {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|ARM.Build.0 = Debug|ARM {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|Mixed Platforms.Build.0 = Debug|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|x64.ActiveCfg = Debug|x64 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|x64.Build.0 = Debug|x64 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|x86.ActiveCfg = Debug|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Debug|x86.Build.0 = Debug|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|Any CPU.Build.0 = Release|Any CPU {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|ARM.ActiveCfg = Release|ARM {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|ARM.Build.0 = Release|ARM {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|Mixed Platforms.ActiveCfg = Release|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|Mixed Platforms.Build.0 = Release|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|x64.ActiveCfg = Release|x64 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|x64.Build.0 = Release|x64 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|x86.ActiveCfg = Release|x86 {95427DE1-88B5-4679-9D96-B7AC4739A7FA}.Release|x86.Build.0 = Release|x86 {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|Any CPU.Build.0 = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|ARM.ActiveCfg = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|x64.ActiveCfg = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Debug|x86.ActiveCfg = Debug|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|Any CPU.ActiveCfg = Release|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|Any CPU.Build.0 = Release|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|ARM.ActiveCfg = Release|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|Mixed Platforms.Build.0 = Release|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|x64.ActiveCfg = Release|Any CPU {19F83E93-3679-4A93-8E3B-707050A96E85}.Release|x86.ActiveCfg = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|Any CPU.Build.0 = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|ARM.ActiveCfg = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|x64.ActiveCfg = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Debug|x86.ActiveCfg = Debug|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|Any CPU.ActiveCfg = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|Any CPU.Build.0 = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|ARM.ActiveCfg = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|Mixed Platforms.Build.0 = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|x64.ActiveCfg = Release|Any CPU {954977A1-6134-4F60-A0B7-FF041828E267}.Release|x86.ActiveCfg = Release|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|Any CPU.Build.0 = Debug|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|ARM.ActiveCfg = Debug|ARM {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|ARM.Build.0 = Debug|ARM {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|ARM.Deploy.0 = Debug|ARM {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|Mixed Platforms.Build.0 = Debug|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|Mixed Platforms.Deploy.0 = Debug|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|x64.ActiveCfg = Debug|x64 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|x64.Build.0 = Debug|x64 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|x64.Deploy.0 = Debug|x64 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|x86.ActiveCfg = Debug|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|x86.Build.0 = Debug|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Debug|x86.Deploy.0 = Debug|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|Any CPU.ActiveCfg = Release|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Release|Any CPU.Build.0 = Release|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Release|Any CPU.Deploy.0 = Release|Any CPU {257EBC11-3373-49B2-AD05-2054E8761961}.Release|ARM.ActiveCfg = Release|ARM {257EBC11-3373-49B2-AD05-2054E8761961}.Release|ARM.Build.0 = Release|ARM {257EBC11-3373-49B2-AD05-2054E8761961}.Release|ARM.Deploy.0 = Release|ARM {257EBC11-3373-49B2-AD05-2054E8761961}.Release|Mixed Platforms.ActiveCfg = Release|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|Mixed Platforms.Build.0 = Release|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|Mixed Platforms.Deploy.0 = Release|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|x64.ActiveCfg = Release|x64 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|x64.Build.0 = Release|x64 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|x64.Deploy.0 = Release|x64 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|x86.ActiveCfg = Release|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|x86.Build.0 = Release|x86 {257EBC11-3373-49B2-AD05-2054E8761961}.Release|x86.Deploy.0 = Release|x86 {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|ARM.ActiveCfg = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|x64.ActiveCfg = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Debug|x86.ActiveCfg = Debug|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|Any CPU.Build.0 = Release|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|ARM.ActiveCfg = Release|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|Mixed Platforms.Build.0 = Release|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|x64.ActiveCfg = Release|Any CPU {EC52A094-1CDB-4F5D-8A8A-86F501FC601C}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {A8993045-3923-488D-BCD5-F7C1F81ACDED} = {AEDAD4B4-9F2C-4992-8CD6-A43DFDFF7172} {257EBC11-3373-49B2-AD05-2054E8761961} = {AEDAD4B4-9F2C-4992-8CD6-A43DFDFF7172} EndGlobalSection EndGlobal ================================================ FILE: src/njake.js ================================================ (function () { var spawn = require('child_process').spawn, path = require('path'), fs = require('fs'); var extend = function (obj) { var args = Array.prototype.slice.call(arguments); if (args.length == 0) return {}; args.slice(1).forEach(function (source) { for (var prop in source) obj[prop] = source[prop]; }); return obj; }; exports.exec = function (cmd, opts, callback) { var command = spawn(cmd, opts || [], { customFds: [0, 1, 2] }); command.on('exit', function (code) { if (callback) callback(code); }); }; exports.msbuild = (function () { var defaults = { processor: 'x86', version: 'net2.0' }; var task = function (opts, callback) { var opt = extend({}, defaults, opts), args = []; if (!opt.file) fail('msbuild failed - file required'); if (!opt._exe) { if (!opt.processor) fail('msbuild failed - processor required'); if (!opt.version) fail('msbuild failed - version required'); opt._exe = exports.getDotNetVersionPath(opt.version, opt.processor) + 'MSBuild.exe'; } args.push(opt.file); if (opt.targets) opts.targets.forEach(function (target) { args.push('/t:' + target); }); if (opt.properties) { for (var key in opt.properties) args.push('/p:' + key + '=' + opt.properties[key]) } args.push.apply(args, opt._parameters || []); exports.exec(opt._exe, args, function (code) { if (code !== 0) fail('msbuild failed') callback ? callback(code) : complete(); }); }; task.setDefaults = function (opts) { extend(defaults, opts); return defaults; }; return task; })(); exports.xunit = (function () { var defaults = {}; var task = function (opts, callback) { var opt = extend({}, defaults, opts), args = []; if (!opt._exe) fail('xunit failed - _exe required'); if (!opt.assembly) fail('xunit failed - assembly required'); args.push(opt.assembly); args.push.apply(args, opt._parameters || []); exports.exec(opt._exe, args, function (code) { if (code !== 0) fail('xunit failed') callback ? callback(code) : complete(); }); }; task.setDefaults = function (opts) { extend(defaults, opts); return defaults; }; return task; })(); exports.nunit = (function () { var defaults = {}; var task = function (opts, callback) { var opt = extend({}, defaults, opts), args = []; if (!opt._exe) fail('nunit failed - _exe required'); if (!opt.assemblies) failed('nunit failed - assemblies required'); opt.assemblies.forEach(function (assembly) { args.push(assembly); }); if(opt.nologo) args.push('/nologo'); if(opt.noshadow) args.push('/noshadow'); if(opt.nothread) args.push('/nothread'); if(opt.nodots) args.push('/nodots'); if(opt.timeout) args.push('/timeout=' + opt.timeout) if(opt.xml) args.push('/xml=' + opt.xml); args.push.apply(args, opt._parameters || []); exports.exec(opt._exe, args, function (code) { if (code !== 0) fail('nunit failed'); callback ? callback(code) : complete(); }); }; task.setDefaults = function (opts) { extend(defaults, opts); return defaults; }; return task; })(); exports.nuget = (function () { var defaults = { _exe: 'NuGet.exe' }; var task = {}; task.pack = function (opts, callback) { var opt = extend({}, defaults, opts), args = []; args.push('pack'); if (!opt._exe) fail('nuget.pack failed - _exe required'); if (!opt.nuspec) fail('nuget.pack failed - nuspec required'); args.push(opt.nuspec); if (opt.outputDirectory) { args.push('-OutputDirectory') args.push(opt.outputDirectory); } if (opt.verbose) args.push('-Verbose'); if (opt.version) { args.push('-Version'); args.push(opt.version); } if (opt.properties) { for (var key in opt.properties) { args.push('-Properties'); args.push(key + '=' + opt.properties[key]) } } args.push.apply(args, opt._parameters || []); exports.exec(opt._exe, args, function (code) { if (code !== 0) fail('nuget.pack failed') callback ? callback(code) : complete(); }); }; task.push = function (opts, callback) { var opt = extend({}, defaults, opts), args = []; args.push('push'); if (!opt._exe) fail('nuget.push failed - _exe required'); if (!opt.package) fail('nuget.push failed - package required'); args.push(opt.package); if (opt.apiKey) args.push(opt.apiKey); if (opt.createOnly) args.push('-CreateOnly'); if (opt.source && opt.source !== '') { args.push('-Source'); args.push(opt.source); } args.push.apply(args, opt._parameters || []); exports.exec(opt._exe, args, function (code) { if (code !== 0) fail('nuget.push failed'); callback ? callback(code) : complete(); }); }; task.setDefaults = function (opts) { extend(defaults, opts); return defaults; }; task.sources = { symbolSource: 'http://nuget.gw.symbolsource.org/Public/NuGet' }; return task; })(); exports.assemblyInfo = (function () { var defaults = { language: 'c#', namespaces: ['System.Reflection', 'System.Runtime.InteropServices'] }; var supportedLangagues = ['c#']; var task = function (opts, callback) { var opt = extend({}, defaults, opts), contents = '', assemblyValue; if (!opt.file) fail('assemblyInfo failed - file required'); if (!opt.language) fail('assemblyInfo failed - language required'); if (opt.language === 'c#') { if (opt.namespaces) { opt.namespaces.forEach(function (ns) { contents += 'using ' + ns + ';\r\n'; }); } if (opt.assembly) { for (var key in opt.assembly) { assemblyValue = opt.assembly[key]; if (typeof assemblyValue === 'function') { contents += assemblyValue(); continue; } contents += '[assembly: ' + key + '('; if (typeof assemblyValue === 'boolean') contents += assemblyValue ? 'true' : 'false'; else contents += '\"' + assemblyValue + '\"'; contents += ')]\r\n'; } } fs.writeFileSync(opt.file, contents); } else { fail('assemblyInfo failed - unsupported language. choose ' + supportedLangagues); } callback ? callback(0) : complete(); }; task.setDefaults = function (opts) { extend(defaults, opts); return defaults; } return task; })(); exports.getWinDir = function () { var winDir = process.env.WINDIR; return path.normalize((winDir.substr(-1) === '/' || winDir.substr(-1) === '\\') ? winDir : (winDir + '/')); // append / if absent }; exports.dotNetVersionMapper = { 'processor': { 'x86': 'Framework', 'x64': 'Framework64' }, 'version': { 'net1.0': '1.0.3705', 'net1.1': '1.1.4322', 'net2.0': '2.0.50727', 'net3.5': '3.5', 'net4.0': '4.0.30319' } }; exports.getDotNetVersionPath = function (version, processor) { // http://msdn.microsoft.com/en-us/library/dd414023.aspx // http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Grouping_Assemblies_by_Framework_Version // make it processor instead of bit, just incase MS releases FrameworkARM ;) var actualProcessor = exports.dotNetVersionMapper['processor'][processor]; var actualVersion = exports.dotNetVersionMapper['version'][version]; if (typeof actualProcessor === 'undefined' || typeof actualVersion === 'undefined') { fail('specified .NET framework is not supported : ' + version + '(' + processor + ')'); return; } var netFrameworkPath = exports.getWinDir() + 'Microsoft.Net\\' + exports.dotNetVersionMapper['processor'][processor] + '\\v' + exports.dotNetVersionMapper['version'][version] + '\\'; return netFrameworkPath; }; })(); ================================================ FILE: src/packages/NUnit.2.5.10.11092/NUnitFitTests.html ================================================

NUnit Acceptance Tests

Developers love self-referential programs! Hence, NUnit has always run all it's own tests, even those that are not really unit tests.

Now, beginning with NUnit 2.4, NUnit has top-level tests using Ward Cunningham's FIT framework. At this time, the tests are pretty rudimentary, but it's a start and it's a framework for doing more.

Running the Tests

Open a console or shell window and navigate to the NUnit bin directory, which contains this file. To run the test under Microsoft .Net, enter the command

    runFile NUnitFitTests.html TestResults.html .
To run it under Mono, enter
    mono runFile.exe NUnitFitTests.html TestResults.html .
Note the space and dot at the end of each command. The results of your test will be in TestResults.html in the same directory.

Platform and CLR Version

NUnit.Fixtures.PlatformInfo

Verify Unit Tests

Load and run the NUnit unit tests, verifying that the results are as expected. When these tests are run on different platforms, different numbers of tests may be skipped, so the values for Skipped and Run tests are informational only.

The number of tests in each assembly should be constant across all platforms - any discrepancy usually means that one of the test source files was not compiled on the platform. There should be no failures and no tests ignored.

Note: At the moment, the nunit.extensions.tests assembly is failing because the fixture doesn't initialize addins in the test domain.

NUnit.Fixtures.AssemblyRunner
Assembly Tests() Run() Skipped() Ignored() Failures()
nunit.framework.tests.dll 397     0 0
nunit.core.tests.dll 355     0 0
nunit.util.tests.dll 238     0 0
nunit.mocks.tests.dll 43     0 0
nunit.extensions.tests.dll 5     0 0
nunit-console.tests.dll 40     0 0
nunit.uikit.tests.dll 34     0 0
nunit-gui.tests.dll 15     0 0
nunit.fixtures.tests.dll 6     0 0

Code Snippet Tests

These tests create a test assembly from a snippet of code and then load and run the tests that it contains, verifying that the structure of the loaded tests is as expected and that the number of tests run, skipped, ignored or failed is correct.

NUnit.Fixtures.SnippetRunner
Code Tree() Run() Skipped() Ignored() Failures()
public class TestClass
{
}
EMPTY 0 0 0 0
using NUnit.Framework;

[TestFixture]
public class TestClass
{
}
TestClass 0 0 0 0
using NUnit.Framework;

[TestFixture]
public class TestClass
{
    [Test]
    public void T1() { }
    [Test]
    public void T2() { }
    [Test]
    public void T3() { }
}
TestClass
>T1
>T2
>T3
3 0 0 0
using NUnit.Framework;

[TestFixture]
public class TestClass1
{
    [Test]
    public void T1() { }
}

[TestFixture]
public class TestClass2
{
    [Test]
    public void T2() { }
    [Test]
    public void T3() { }
}
TestClass1
>T1
TestClass2
>T2
>T3
3 0 0 0
using NUnit.Framework;

[TestFixture]
public class TestClass
{
    [Test]
    public void T1() { }
    [Test, Ignore]
    public void T2() { }
    [Test]
    public void T3() { }
}
TestClass
>T1
>T2
>T3
2 0 1 0
using NUnit.Framework;

[TestFixture]
public class TestClass
{
    [Test]
    public void T1() { }
    [Test, Explicit]
    public void T2() { }
    [Test]
    public void T3() { }
}
TestClass
>T1
>T2
>T3
2 1 0 0

Summary Information

fit.Summary
================================================ FILE: src/packages/NUnit.2.5.10.11092/fit-license.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ================================================ FILE: src/packages/NUnit.2.5.10.11092/lib/nunit.framework.xml ================================================ nunit.framework Attribute used to apply a category to a test The name of the category Construct attribute for a given category based on a name. The name may not contain the characters ',', '+', '-' or '!'. However, this is not checked in the constructor since it would cause an error to arise at as the test was loaded without giving a clear indication of where the problem is located. The error is handled in NUnitFramework.cs by marking the test as not runnable. The name of the category Protected constructor uses the Type name as the name of the category. The name of the category Used to mark a field for use as a datapoint when executing a theory within the same fixture that requires an argument of the field's Type. Used to mark an array as containing a set of datapoints to be used executing a theory within the same fixture that requires an argument of the Type of the array elements. Attribute used to provide descriptive text about a test case or fixture. Construct the attribute Text describing the test Gets the test description Enumeration indicating how the expected message parameter is to be used Expect an exact match Expect a message containing the parameter string Match the regular expression provided as a parameter Expect a message that starts with the parameter string ExpectedExceptionAttribute Constructor for a non-specific exception Constructor for a given type of exception The type of the expected exception Constructor for a given exception name The full name of the expected exception Gets or sets the expected exception type Gets or sets the full Type name of the expected exception Gets or sets the expected message text Gets or sets the user message displayed in case of failure Gets or sets the type of match to be performed on the expected message Gets the name of a method to be used as an exception handler ExplicitAttribute marks a test or test fixture so that it will only be run if explicitly executed from the gui or command line or if it is included by use of a filter. The test will not be run simply because an enclosing suite is run. Default constructor Constructor with a reason The reason test is marked explicit The reason test is marked explicit Attribute used to mark a test that is to be ignored. Ignored tests result in a warning message when the tests are run. Constructs the attribute without giving a reason for ignoring the test. Constructs the attribute giving a reason for ignoring the test The reason for ignoring the test The reason for ignoring a test Abstract base for Attributes that are used to include tests in the test run based on environmental settings. Constructor with no included items specified, for use with named property syntax. Constructor taking one or more included items Comma-delimited list of included items Name of the item that is needed in order for a test to run. Multiple itemss may be given, separated by a comma. Name of the item to be excluded. Multiple items may be given, separated by a comma. The reason for including or excluding the test PlatformAttribute is used to mark a test fixture or an individual method as applying to a particular platform only. Constructor with no platforms specified, for use with named property syntax. Constructor taking one or more platforms Comma-deliminted list of platforms CultureAttribute is used to mark a test fixture or an individual method as applying to a particular Culture only. Constructor with no cultures specified, for use with named property syntax. Constructor taking one or more cultures Comma-deliminted list of cultures Marks a test to use a combinatorial join of any argument data provided. NUnit will create a test case for every combination of the arguments provided. This can result in a large number of test cases and so should be used judiciously. This is the default join type, so the attribute need not be used except as documentation. PropertyAttribute is used to attach information to a test as a name/value pair.. Construct a PropertyAttribute with a name and string value The name of the property The property value Construct a PropertyAttribute with a name and int value The name of the property The property value Construct a PropertyAttribute with a name and double value The name of the property The property value Constructor for derived classes that set the property dictionary directly. Constructor for use by derived classes that use the name of the type as the property name. Derived classes must ensure that the Type of the property value is a standard type supported by the BCL. Any custom types will cause a serialization Exception when in the client. Gets the property dictionary for this attribute Default constructor Marks a test to use pairwise join of any argument data provided. NUnit will attempt too excercise every pair of argument values at least once, using as small a number of test cases as it can. With only two arguments, this is the same as a combinatorial join. Default constructor Marks a test to use a sequential join of any argument data provided. NUnit will use arguements for each parameter in sequence, generating test cases up to the largest number of argument values provided and using null for any arguments for which it runs out of values. Normally, this should be used with the same number of arguments for each parameter. Default constructor Summary description for MaxTimeAttribute. Construct a MaxTimeAttribute, given a time in milliseconds. The maximum elapsed time in milliseconds RandomAttribute is used to supply a set of random values to a single parameter of a parameterized test. ValuesAttribute is used to provide literal arguments for an individual parameter of a test. Abstract base class for attributes that apply to parameters and supply data for the parameter. Gets the data to be provided to the specified parameter The collection of data to be returned. Must be set by any derived attribute classes. We use an object[] so that the individual elements may have their type changed in GetData if necessary. Construct with one argument Construct with two arguments Construct with three arguments Construct with an array of arguments Get the collection of values to be used as arguments Construct a set of doubles from 0.0 to 1.0, specifying only the count. Construct a set of doubles from min to max Construct a set of ints from min to max Get the collection of values to be used as arguments RangeAttribute is used to supply a range of values to an individual parameter of a parameterized test. Construct a range of ints using default step of 1 Construct a range of ints specifying the step size Construct a range of longs Construct a range of doubles Construct a range of floats RepeatAttribute may be applied to test case in order to run it multiple times. Construct a RepeatAttribute The number of times to run the test RequiredAddinAttribute may be used to indicate the names of any addins that must be present in order to run some or all of the tests in an assembly. If the addin is not loaded, the entire assembly is marked as NotRunnable. Initializes a new instance of the class. The required addin. Gets the name of required addin. The required addin name. Summary description for SetCultureAttribute. Construct given the name of a culture Summary description for SetUICultureAttribute. Construct given the name of a culture Attribute used to mark a class that contains one-time SetUp and/or TearDown methods that apply to all the tests in a namespace or an assembly. SetUpFixtureAttribute is used to identify a SetUpFixture Attribute used to mark a static (shared in VB) property that returns a list of tests. Attribute used to identify a method that is called immediately after each test is run. The method is guaranteed to be called, even if an exception is thrown. Adding this attribute to a method within a class makes the method callable from the NUnit test runner. There is a property called Description which is optional which you can provide a more detailed test description. This class cannot be inherited. [TestFixture] public class Fixture { [Test] public void MethodToTest() {} [Test(Description = "more detailed description")] publc void TestDescriptionMethod() {} } Descriptive text for this test TestCaseAttribute is used to mark parameterized test cases and provide them with their arguments. The ITestCaseData interface is implemented by a class that is able to return complete testcases for use by a parameterized test method. NOTE: This interface is used in both the framework and the core, even though that results in two different types. However, sharing the source code guarantees that the various implementations will be compatible and that the core is able to reflect successfully over the framework implementations of ITestCaseData. Gets the argument list to be provided to the test Gets the expected result Gets the expected exception Type Gets the FullName of the expected exception Gets the name to be used for the test Gets the description of the test Gets a value indicating whether this is ignored. true if ignored; otherwise, false. Gets the ignore reason. The ignore reason. Construct a TestCaseAttribute with a list of arguments. This constructor is not CLS-Compliant Construct a TestCaseAttribute with a single argument Construct a TestCaseAttribute with a two arguments Construct a TestCaseAttribute with a three arguments Gets the list of arguments to a test case Gets or sets the expected result. The result. Gets a list of categories associated with this test; Gets or sets the category associated with this test. May be a single category or a comma-separated list. Gets or sets the expected exception. The expected exception. Gets or sets the name the expected exception. The expected name of the exception. Gets or sets the expected message of the expected exception The expected message of the exception. Gets or sets the type of match to be performed on the expected message Gets or sets the description. The description. Gets or sets the name of the test. The name of the test. Gets or sets the ignored status of the test Gets or sets the ignored status of the test Gets the ignore reason. The ignore reason. FactoryAttribute indicates the source to be used to provide test cases for a test method. Construct with the name of the factory - for use with languages that don't support params arrays. An array of the names of the factories that will provide data Construct with a Type and name - for use with languages that don't support params arrays. The Type that will provide data The name of the method, property or field that will provide data The name of a the method, property or fiend to be used as a source A Type to be used as a source [TestFixture] public class ExampleClass {} Default constructor Construct with a object[] representing a set of arguments. In .NET 2.0, the arguments may later be separated into type arguments and constructor arguments. Descriptive text for this fixture Gets and sets the category for this fixture. May be a comma-separated list of categories. Gets a list of categories for this fixture The arguments originally provided to the attribute Gets or sets a value indicating whether this should be ignored. true if ignore; otherwise, false. Gets or sets the ignore reason. May set Ignored as a side effect. The ignore reason. Get or set the type arguments. If not set explicitly, any leading arguments that are Types are taken as type arguments. Attribute used to identify a method that is called before any tests in a fixture are run. Attribute used to identify a method that is called after all the tests in a fixture have run. The method is guaranteed to be called, even if an exception is thrown. Adding this attribute to a method within a class makes the method callable from the NUnit test runner. There is a property called Description which is optional which you can provide a more detailed test description. This class cannot be inherited. [TestFixture] public class Fixture { [Test] public void MethodToTest() {} [Test(Description = "more detailed description")] publc void TestDescriptionMethod() {} } WUsed on a method, marks the test with a timeout value in milliseconds. The test will be run in a separate thread and is cancelled if the timeout is exceeded. Used on a method or assembly, sets the default timeout for all contained test methods. Construct a TimeoutAttribute given a time in milliseconds The timeout value in milliseconds Marks a test that must run in the STA, causing it to run in a separate thread if necessary. On methods, you may also use STAThreadAttribute to serve the same purpose. Construct a RequiresSTAAttribute Marks a test that must run in the MTA, causing it to run in a separate thread if necessary. On methods, you may also use MTAThreadAttribute to serve the same purpose. Construct a RequiresMTAAttribute Marks a test that must run on a separate thread. Construct a RequiresThreadAttribute Construct a RequiresThreadAttribute, specifying the apartment ValueSourceAttribute indicates the source to be used to provide data for one parameter of a test method. Construct with the name of the factory - for use with languages that don't support params arrays. The name of the data source to be used Construct with a Type and name - for use with languages that don't support params arrays. The Type that will provide data The name of the method, property or field that will provide data The name of a the method, property or fiend to be used as a source A Type to be used as a source AttributeExistsConstraint tests for the presence of a specified attribute on a Type. The Constraint class is the base of all built-in constraints within NUnit. It provides the operator overloads used to combine constraints. The IConstraintExpression interface is implemented by all complete and resolvable constraints and expressions. Return the top-level constraint for this expression Static UnsetObject used to detect derived constraints failing to set the actual value. The actual value being tested against a constraint The display name of this Constraint for use by ToString() Argument fields used by ToString(); The builder holding this constraint Construct a constraint with no arguments Construct a constraint with one argument Construct a constraint with two arguments Sets the ConstraintBuilder holding this constraint Write the failure message to the MessageWriter provided as an argument. The default implementation simply passes the constraint and the actual value to the writer, which then displays the constraint description and the value. Constraints that need to provide additional details, such as where the error occured can override this. The MessageWriter on which to display the message Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Test whether the constraint is satisfied by an ActualValueDelegate that returns the value to be tested. The default implementation simply evaluates the delegate but derived classes may override it to provide for delayed processing. An ActualValueDelegate True for success, false for failure Test whether the constraint is satisfied by a given reference. The default implementation simply dereferences the value but derived classes may override it to provide for delayed processing. A reference to the value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed Default override of ToString returns the constraint DisplayName followed by any arguments within angle brackets. Returns the string representation of this constraint This operator creates a constraint that is satisfied only if both argument constraints are satisfied. This operator creates a constraint that is satisfied if either of the argument constraints is satisfied. This operator creates a constraint that is satisfied if the argument constraint is not satisfied. Returns a DelayedConstraint with the specified delay time. The delay in milliseconds. Returns a DelayedConstraint with the specified delay time and polling interval. The delay in milliseconds. The interval at which to test the constraint. The display name of this Constraint for use by ToString(). The default value is the name of the constraint with trailing "Constraint" removed. Derived classes may set this to another name in their constructors. Returns a ConstraintExpression by appending And to the current constraint. Returns a ConstraintExpression by appending And to the current constraint. Returns a ConstraintExpression by appending Or to the current constraint. Class used to detect any derived constraints that fail to set the actual value in their Matches override. Constructs an AttributeExistsConstraint for a specific attribute Type Tests whether the object provides the expected attribute. A Type, MethodInfo, or other ICustomAttributeProvider True if the expected attribute is present, otherwise false Writes the description of the constraint to the specified writer AttributeConstraint tests that a specified attribute is present on a Type or other provider and that the value of the attribute satisfies some other constraint. Abstract base class used for prefixes The base constraint Construct given a base constraint Constructs an AttributeConstraint for a specified attriute Type and base constraint. Determines whether the Type or other provider has the expected attribute and if its value matches the additional constraint specified. Writes a description of the attribute to the specified writer. Writes the actual value supplied to the specified writer. Returns a string representation of the constraint. BasicConstraint is the abstract base for constraints that perform a simple comparison to a constant value. Initializes a new instance of the class. The expected. The description. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed NullConstraint tests that the actual value is null Initializes a new instance of the class. TrueConstraint tests that the actual value is true Initializes a new instance of the class. FalseConstraint tests that the actual value is false Initializes a new instance of the class. NaNConstraint tests that the actual value is a double or float NaN Test that the actual value is an NaN Write the constraint description to a specified writer BinaryConstraint is the abstract base of all constraints that combine two other constraints in some fashion. The first constraint being combined The second constraint being combined Construct a BinaryConstraint from two other constraints The first constraint The second constraint AndConstraint succeeds only if both members succeed. Create an AndConstraint from two other constraints The first constraint The second constraint Apply both member constraints to an actual value, succeeding succeeding only if both of them succeed. The actual value True if the constraints both succeeded Write a description for this contraint to a MessageWriter The MessageWriter to receive the description Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed OrConstraint succeeds if either member succeeds Create an OrConstraint from two other constraints The first constraint The second constraint Apply the member constraints to an actual value, succeeding succeeding as soon as one of them succeeds. The actual value True if either constraint succeeded Write a description for this contraint to a MessageWriter The MessageWriter to receive the description CollectionConstraint is the abstract base class for constraints that operate on collections. Construct an empty CollectionConstraint Construct a CollectionConstraint Determines whether the specified enumerable is empty. The enumerable. true if the specified enumerable is empty; otherwise, false. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Protected method to be implemented by derived classes CollectionItemsEqualConstraint is the abstract base class for all collection constraints that apply some notion of item equality as a part of their operation. Construct an empty CollectionConstraint Construct a CollectionConstraint Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied Comparison object. The IComparer object to use. Self. Flag the constraint to use the supplied IEqualityComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IEqualityComparer object. The IComparer object to use. Self. Compares two collection members for equality Return a new CollectionTally for use in making tests The collection to be included in the tally Flag the constraint to ignore case and return self. EmptyCollectionConstraint tests whether a collection is empty. Check that the collection is empty Write the constraint description to a MessageWriter UniqueItemsConstraint tests whether all the items in a collection are unique. Check that all items are unique. Write a description of this constraint to a MessageWriter CollectionContainsConstraint is used to test whether a collection contains an expected object as a member. Construct a CollectionContainsConstraint Test whether the expected item is contained in the collection Write a descripton of the constraint to a MessageWriter CollectionEquivalentCOnstraint is used to determine whether two collections are equivalent. Construct a CollectionEquivalentConstraint Test whether two collections are equivalent Write a description of this constraint to a MessageWriter CollectionSubsetConstraint is used to determine whether one collection is a subset of another Construct a CollectionSubsetConstraint The collection that the actual value is expected to be a subset of Test whether the actual collection is a subset of the expected collection provided. Write a description of this constraint to a MessageWriter CollectionOrderedConstraint is used to test whether a collection is ordered. Construct a CollectionOrderedConstraint Modifies the constraint to use an IComparer and returns self. Modifies the constraint to use an IComparer<T> and returns self. Modifies the constraint to use a Comparison<T> and returns self. Modifies the constraint to test ordering by the value of a specified property and returns self. Test whether the collection is ordered Write a description of the constraint to a MessageWriter Returns the string representation of the constraint. If used performs a reverse comparison CollectionTally counts (tallies) the number of occurences of each object in one or more enumerations. Construct a CollectionTally object from a comparer and a collection Try to remove an object from the tally The object to remove True if successful, false if the object was not found Try to remove a set of objects from the tally The objects to remove True if successful, false if any object was not found The number of objects remaining in the tally ComparisonAdapter class centralizes all comparisons of values in NUnit, adapting to the use of any provided IComparer, IComparer<T> or Comparison<T> Returns a ComparisonAdapter that wraps an IComparer Returns a ComparisonAdapter that wraps an IComparer<T> Returns a ComparisonAdapter that wraps a Comparison<T> Compares two objects Gets the default ComparisonAdapter, which wraps an NUnitComparer object. Construct a ComparisonAdapter for an IComparer Compares two objects Construct a default ComparisonAdapter ComparisonAdapter<T> extends ComparisonAdapter and allows use of an IComparer<T> or Comparison<T> to actually perform the comparison. Construct a ComparisonAdapter for an IComparer<T> Compare a Type T to an object Construct a ComparisonAdapter for a Comparison<T> Compare a Type T to an object Abstract base class for constraints that compare values to determine if one is greater than, equal to or less than the other. The value against which a comparison is to be made If true, less than returns success if true, equal returns success if true, greater than returns success The predicate used as a part of the description ComparisonAdapter to be used in making the comparison Initializes a new instance of the class. The value against which to make a comparison. if set to true less succeeds. if set to true equal succeeds. if set to true greater succeeds. String used in describing the constraint. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Modifies the constraint to use an IComparer and returns self Modifies the constraint to use an IComparer<T> and returns self Modifies the constraint to use a Comparison<T> and returns self Tests whether a value is greater than the value supplied to its constructor Initializes a new instance of the class. The expected value. Tests whether a value is greater than or equal to the value supplied to its constructor Initializes a new instance of the class. The expected value. Tests whether a value is less than the value supplied to its constructor Initializes a new instance of the class. The expected value. Tests whether a value is less than or equal to the value supplied to its constructor Initializes a new instance of the class. The expected value. Delegate used to delay evaluation of the actual value to be used in evaluating a constraint ConstraintBuilder maintains the stacks that are used in processing a ConstraintExpression. An OperatorStack is used to hold operators that are waiting for their operands to be reognized. a ConstraintStack holds input constraints as well as the results of each operator applied. Initializes a new instance of the class. Appends the specified operator to the expression by first reducing the operator stack and then pushing the new operator on the stack. The operator to push. Appends the specified constraint to the expresson by pushing it on the constraint stack. The constraint to push. Sets the top operator right context. The right context. Reduces the operator stack until the topmost item precedence is greater than or equal to the target precedence. The target precedence. Resolves this instance, returning a Constraint. If the builder is not currently in a resolvable state, an exception is thrown. The resolved constraint Gets a value indicating whether this instance is resolvable. true if this instance is resolvable; otherwise, false. OperatorStack is a type-safe stack for holding ConstraintOperators Initializes a new instance of the class. The builder. Pushes the specified operator onto the stack. The op. Pops the topmost operator from the stack. Gets a value indicating whether this is empty. true if empty; otherwise, false. Gets the topmost operator without modifying the stack. The top. ConstraintStack is a type-safe stack for holding Constraints Initializes a new instance of the class. The builder. Pushes the specified constraint. As a side effect, the constraint's builder field is set to the ConstraintBuilder owning this stack. The constraint. Pops this topmost constrait from the stack. As a side effect, the constraint's builder field is set to null. Gets a value indicating whether this is empty. true if empty; otherwise, false. Gets the topmost constraint without modifying the stack. The topmost constraint ConstraintExpression represents a compound constraint in the process of being constructed from a series of syntactic elements. Individual elements are appended to the expression as they are reognized. Once an actual Constraint is appended, the expression returns a resolvable Constraint. ConstraintExpressionBase is the abstract base class for the generated ConstraintExpression class, which represents a compound constraint in the process of being constructed from a series of syntactic elements. NOTE: ConstraintExpressionBase is aware of some of its derived classes, which is an apparent violation of encapsulation. Ideally, these classes would be a single class, but they must be separated in order to allow parts to be generated under .NET 1.x and to provide proper user feedback in syntactically aware IDEs. The ConstraintBuilder holding the elements recognized so far Initializes a new instance of the class. Initializes a new instance of the class passing in a ConstraintBuilder, which may be pre-populated. The builder. Returns a string representation of the expression as it currently stands. This should only be used for testing, since it has the side-effect of resolving the expression. Appends an operator to the expression and returns the resulting expression itself. Appends a self-resolving operator to the expression and returns a new ResolvableConstraintExpression. Appends a constraint to the expression and returns that constraint, which is associated with the current state of the expression being built. Initializes a new instance of the class. Initializes a new instance of the class passing in a ConstraintBuilder, which may be pre-populated. The builder. Returns a new PropertyConstraintExpression, which will either test for the existence of the named property on the object being tested or apply any following constraint to that property. Returns a new AttributeConstraint checking for the presence of a particular attribute on an object. Returns a new AttributeConstraint checking for the presence of a particular attribute on an object. Returns the constraint provided as an argument - used to allow custom custom constraints to easily participate in the syntax. Returns the constraint provided as an argument - used to allow custom custom constraints to easily participate in the syntax. Returns a constraint that tests two items for equality Returns a constraint that tests that two references are the same object Returns a constraint that tests whether the actual value is greater than the suppled argument Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument Returns a constraint that tests whether the actual value is less than the suppled argument Returns a constraint that tests whether the actual value is less than or equal to the suppled argument Returns a constraint that tests whether the actual value is less than or equal to the suppled argument Returns a constraint that tests whether the actual value is of the exact type supplied as an argument. Returns a constraint that tests whether the actual value is of the exact type supplied as an argument. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is a collection containing the same elements as the collection supplied as an argument. Returns a constraint that tests whether the actual value is a subset of the collection supplied as an argument. Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection. Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection. Returns a new ContainsConstraint. This constraint will, in turn, make use of the appropriate second-level constraint, depending on the type of the actual argument. This overload is only used if the item sought is a string, since any other type implies that we are looking for a collection member. Returns a constraint that succeeds if the actual value contains the substring supplied as an argument. Returns a constraint that succeeds if the actual value contains the substring supplied as an argument. Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument. Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument. Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument. Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument. Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument. Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument. Returns a constraint that tests whether the path provided is the same as an expected path after canonicalization. Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization. Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization. Returns a constraint that tests whether the actual value falls within a specified range. Returns a ConstraintExpression that negates any following constraint. Returns a ConstraintExpression that negates any following constraint. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if at least one of them succeeds. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them fail. Returns a new ConstraintExpression, which will apply the following constraint to the Length property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the Count property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the Message property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the InnerException property of the object being tested. With is currently a NOP - reserved for future use. Returns a constraint that tests for null Returns a constraint that tests for True Returns a constraint that tests for False Returns a constraint that tests for NaN Returns a constraint that tests for empty Returns a constraint that tests whether a collection contains all unique items. Returns a constraint that tests whether an object graph is serializable in binary format. Returns a constraint that tests whether an object graph is serializable in xml format. Returns a constraint that tests whether a collection is ordered Helper class with properties and methods that supply a number of constraints used in Asserts. Returns a new PropertyConstraintExpression, which will either test for the existence of the named property on the object being tested or apply any following constraint to that property. Returns a new AttributeConstraint checking for the presence of a particular attribute on an object. Returns a new AttributeConstraint checking for the presence of a particular attribute on an object. Returns a constraint that tests two items for equality Returns a constraint that tests that two references are the same object Returns a constraint that tests whether the actual value is greater than the suppled argument Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument Returns a constraint that tests whether the actual value is less than the suppled argument Returns a constraint that tests whether the actual value is less than or equal to the suppled argument Returns a constraint that tests whether the actual value is less than or equal to the suppled argument Returns a constraint that tests whether the actual value is of the exact type supplied as an argument. Returns a constraint that tests whether the actual value is of the exact type supplied as an argument. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is a collection containing the same elements as the collection supplied as an argument. Returns a constraint that tests whether the actual value is a subset of the collection supplied as an argument. Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection. Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection. Returns a new ContainsConstraint. This constraint will, in turn, make use of the appropriate second-level constraint, depending on the type of the actual argument. This overload is only used if the item sought is a string, since any other type implies that we are looking for a collection member. Returns a constraint that succeeds if the actual value contains the substring supplied as an argument. Returns a constraint that succeeds if the actual value contains the substring supplied as an argument. Returns a constraint that fails if the actual value contains the substring supplied as an argument. Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument. Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument. Returns a constraint that fails if the actual value starts with the substring supplied as an argument. Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument. Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument. Returns a constraint that fails if the actual value ends with the substring supplied as an argument. Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument. Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument. Returns a constraint that fails if the actual value matches the pattern supplied as an argument. Returns a constraint that tests whether the path provided is the same as an expected path after canonicalization. Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization. Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization. Returns a constraint that tests whether the actual value falls within a specified range. Returns a ConstraintExpression that negates any following constraint. Returns a ConstraintExpression that negates any following constraint. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if at least one of them succeeds. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them fail. Returns a new ConstraintExpression, which will apply the following constraint to the Length property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the Count property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the Message property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the InnerException property of the object being tested. Returns a constraint that tests for null Returns a constraint that tests for True Returns a constraint that tests for False Returns a constraint that tests for NaN Returns a constraint that tests for empty Returns a constraint that tests whether a collection contains all unique items. Returns a constraint that tests whether an object graph is serializable in binary format. Returns a constraint that tests whether an object graph is serializable in xml format. Returns a constraint that tests whether a collection is ordered The ConstraintOperator class is used internally by a ConstraintBuilder to represent an operator that modifies or combines constraints. Constraint operators use left and right precedence values to determine whether the top operator on the stack should be reduced before pushing a new operator. The precedence value used when the operator is about to be pushed to the stack. The precedence value used when the operator is on the top of the stack. Reduce produces a constraint from the operator and any arguments. It takes the arguments from the constraint stack and pushes the resulting constraint on it. The syntax element preceding this operator The syntax element folowing this operator The precedence value used when the operator is about to be pushed to the stack. The precedence value used when the operator is on the top of the stack. PrefixOperator takes a single constraint and modifies it's action in some way. Reduce produces a constraint from the operator and any arguments. It takes the arguments from the constraint stack and pushes the resulting constraint on it. Returns the constraint created by applying this prefix to another constraint. Negates the test of the constraint it wraps. Constructs a new NotOperator Returns a NotConstraint applied to its argument. Abstract base for operators that indicate how to apply a constraint to items in a collection. Constructs a CollectionOperator Represents a constraint that succeeds if all the members of a collection match a base constraint. Returns a constraint that will apply the argument to the members of a collection, succeeding if they all succeed. Represents a constraint that succeeds if any of the members of a collection match a base constraint. Returns a constraint that will apply the argument to the members of a collection, succeeding if any of them succeed. Represents a constraint that succeeds if none of the members of a collection match a base constraint. Returns a constraint that will apply the argument to the members of a collection, succeeding if none of them succeed. Represents a constraint that simply wraps the constraint provided as an argument, without any further functionality, but which modifes the order of evaluation because of its precedence. Constructor for the WithOperator Returns a constraint that wraps its argument Abstract base class for operators that are able to reduce to a constraint whether or not another syntactic element follows. Operator used to test for the presence of a named Property on an object and optionally apply further tests to the value of that property. Constructs a PropOperator for a particular named property Reduce produces a constraint from the operator and any arguments. It takes the arguments from the constraint stack and pushes the resulting constraint on it. Gets the name of the property to which the operator applies Operator that tests for the presence of a particular attribute on a type and optionally applies further tests to the attribute. Construct an AttributeOperator for a particular Type The Type of attribute tested Reduce produces a constraint from the operator and any arguments. It takes the arguments from the constraint stack and pushes the resulting constraint on it. Operator that tests that an exception is thrown and optionally applies further tests to the exception. Construct a ThrowsOperator Reduce produces a constraint from the operator and any arguments. It takes the arguments from the constraint stack and pushes the resulting constraint on it. Abstract base class for all binary operators Reduce produces a constraint from the operator and any arguments. It takes the arguments from the constraint stack and pushes the resulting constraint on it. Abstract method that produces a constraint by applying the operator to its left and right constraint arguments. Gets the left precedence of the operator Gets the right precedence of the operator Operator that requires both it's arguments to succeed Construct an AndOperator Apply the operator to produce an AndConstraint Operator that requires at least one of it's arguments to succeed Construct an OrOperator Apply the operator to produce an OrConstraint ContainsConstraint tests a whether a string contains a substring or a collection contains an object. It postpones the decision of which test to use until the type of the actual argument is known. This allows testing whether a string is contained in a collection or as a substring of another string using the same syntax. Initializes a new instance of the class. The expected. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied Comparison object. The IComparer object to use. Self. Flag the constraint to use the supplied IEqualityComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IEqualityComparer object. The IComparer object to use. Self. Flag the constraint to ignore case and return self. Applies a delay to the match so that a match can be evaluated in the future. Creates a new DelayedConstraint The inner constraint two decorate The time interval after which the match is performed If the value of is less than 0 Creates a new DelayedConstraint The inner constraint two decorate The time interval after which the match is performed The time interval used for polling If the value of is less than 0 Test whether the constraint is satisfied by a given value The value to be tested True for if the base constraint fails, false if it succeeds Test whether the constraint is satisfied by a delegate The delegate whose value is to be tested True for if the base constraint fails, false if it succeeds Test whether the constraint is satisfied by a given reference. Overridden to wait for the specified delay period before calling the base constraint with the dereferenced value. A reference to the value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The writer on which the actual value is displayed Returns the string representation of the constraint. EmptyDirectoryConstraint is used to test that a directory is empty Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed EmptyConstraint tests a whether a string or collection is empty, postponing the decision about which test is applied until the type of the actual argument is known. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed EqualConstraint is able to compare an actual value with the expected value provided in its constructor. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If true, strings in error messages will be clipped NUnitEqualityComparer used to test equality. Initializes a new instance of the class. The expected value. Flag the constraint to use a tolerance when determining equality. Tolerance value to be used Self. Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied Comparison object. The IComparer object to use. Self. Flag the constraint to use the supplied IEqualityComparer object. The IComparer object to use. Self. Flag the constraint to use the supplied IEqualityComparer object. The IComparer object to use. Self. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write a failure message. Overridden to provide custom failure messages for EqualConstraint. The MessageWriter to write to Write description of this constraint The MessageWriter to write to Display the failure information for two collections that did not match. The MessageWriter on which to display The expected collection. The actual collection The depth of this failure in a set of nested collections Displays a single line showing the types and sizes of the expected and actual collections or arrays. If both are identical, the value is only shown once. The MessageWriter on which to display The expected collection or array The actual collection or array The indentation level for the message line Displays a single line showing the point in the expected and actual arrays at which the comparison failed. If the arrays have different structures or dimensions, both values are shown. The MessageWriter on which to display The expected array The actual array Index of the failure point in the underlying collections The indentation level for the message line Flag the constraint to ignore case and return self. Flag the constraint to suppress string clipping and return self. Flag the constraint to compare arrays as collections and return self. Switches the .Within() modifier to interpret its tolerance as a distance in representable values (see remarks). Self. Ulp stands for "unit in the last place" and describes the minimum amount a given value can change. For any integers, an ulp is 1 whole digit. For floating point values, the accuracy of which is better for smaller numbers and worse for larger numbers, an ulp depends on the size of the number. Using ulps for comparison of floating point results instead of fixed tolerances is safer because it will automatically compensate for the added inaccuracy of larger numbers. Switches the .Within() modifier to interpret its tolerance as a percentage that the actual values is allowed to deviate from the expected value. Self Causes the tolerance to be interpreted as a TimeSpan in days. Self Causes the tolerance to be interpreted as a TimeSpan in hours. Self Causes the tolerance to be interpreted as a TimeSpan in minutes. Self Causes the tolerance to be interpreted as a TimeSpan in seconds. Self Causes the tolerance to be interpreted as a TimeSpan in milliseconds. Self Causes the tolerance to be interpreted as a TimeSpan in clock ticks. Self EqualityAdapter class handles all equality comparisons that use an IEqualityComparer, IEqualityComparer<T> or a ComparisonAdapter. Compares two objects, returning true if they are equal Returns an EqualityAdapter that wraps an IComparer. Returns an EqualityAdapter that wraps an IEqualityComparer. Returns an EqualityAdapter that wraps an IEqualityComparer<T>. Returns an EqualityAdapter that wraps an IComparer<T>. Returns an EqualityAdapter that wraps a Comparison<T>. Helper routines for working with floating point numbers The floating point comparison code is based on this excellent article: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm "ULP" means Unit in the Last Place and in the context of this library refers to the distance between two adjacent floating point numbers. IEEE floating point numbers can only represent a finite subset of natural numbers, with greater accuracy for smaller numbers and lower accuracy for very large numbers. If a comparison is allowed "2 ulps" of deviation, that means the values are allowed to deviate by up to 2 adjacent floating point values, which might be as low as 0.0000001 for small numbers or as high as 10.0 for large numbers. Compares two floating point values for equality First floating point value to be compared Second floating point value t be compared Maximum number of representable floating point values that are allowed to be between the left and the right floating point values True if both numbers are equal or close to being equal Floating point values can only represent a finite subset of natural numbers. For example, the values 2.00000000 and 2.00000024 can be stored in a float, but nothing inbetween them. This comparison will count how many possible floating point values are between the left and the right number. If the number of possible values between both numbers is less than or equal to maxUlps, then the numbers are considered as being equal. Implementation partially follows the code outlined here: http://www.anttirt.net/2007/08/19/proper-floating-point-comparisons/ Compares two double precision floating point values for equality First double precision floating point value to be compared Second double precision floating point value t be compared Maximum number of representable double precision floating point values that are allowed to be between the left and the right double precision floating point values True if both numbers are equal or close to being equal Double precision floating point values can only represent a limited series of natural numbers. For example, the values 2.0000000000000000 and 2.0000000000000004 can be stored in a double, but nothing inbetween them. This comparison will count how many possible double precision floating point values are between the left and the right number. If the number of possible values between both numbers is less than or equal to maxUlps, then the numbers are considered as being equal. Implementation partially follows the code outlined here: http://www.anttirt.net/2007/08/19/proper-floating-point-comparisons/ Reinterprets the memory contents of a floating point value as an integer value Floating point value whose memory contents to reinterpret The memory contents of the floating point value interpreted as an integer Reinterprets the memory contents of a double precision floating point value as an integer value Double precision floating point value whose memory contents to reinterpret The memory contents of the double precision floating point value interpreted as an integer Reinterprets the memory contents of an integer as a floating point value Integer value whose memory contents to reinterpret The memory contents of the integer value interpreted as a floating point value Reinterprets the memory contents of an integer value as a double precision floating point value Integer whose memory contents to reinterpret The memory contents of the integer interpreted as a double precision floating point value Union of a floating point variable and an integer The union's value as a floating point variable The union's value as an integer The union's value as an unsigned integer Union of a double precision floating point variable and a long The union's value as a double precision floating point variable The union's value as a long The union's value as an unsigned long MessageWriter is the abstract base for classes that write constraint descriptions and messages in some form. The class has separate methods for writing various components of a message, allowing implementations to tailor the presentation as needed. Construct a MessageWriter given a culture Method to write single line message with optional args, usually written to precede the general failure message. The message to be written Any arguments used in formatting the message Method to write single line message with optional args, usually written to precede the general failure message, at a givel indentation level. The indentation level of the message The message to be written Any arguments used in formatting the message Display Expected and Actual lines for a constraint. This is called by MessageWriter's default implementation of WriteMessageTo and provides the generic two-line display. The constraint that failed Display Expected and Actual lines for given values. This method may be called by constraints that need more control over the display of actual and expected values than is provided by the default implementation. The expected value The actual value causing the failure Display Expected and Actual lines for given values, including a tolerance value on the Expected line. The expected value The actual value causing the failure The tolerance within which the test was made Display the expected and actual string values on separate lines. If the mismatch parameter is >=0, an additional line is displayed line containing a caret that points to the mismatch point. The expected string value The actual string value The point at which the strings don't match or -1 If true, case is ignored in locating the point where the strings differ If true, the strings should be clipped to fit the line Writes the text for a connector. The connector. Writes the text for a predicate. The predicate. Writes the text for an expected value. The expected value. Writes the text for a modifier The modifier. Writes the text for an actual value. The actual value. Writes the text for a generalized value. The value. Writes the text for a collection value, starting at a particular point, to a max length The collection containing elements to write. The starting point of the elements to write The maximum number of elements to write Abstract method to get the max line length Static methods used in creating messages Static string used when strings are clipped Returns the representation of a type as used in NUnitLite. This is the same as Type.ToString() except for arrays, which are displayed with their declared sizes. Converts any control characters in a string to their escaped representation. The string to be converted The converted string Return the a string representation for a set of indices into an array Array of indices for which a string is needed Get an array of indices representing the point in a collection or array corresponding to a single int index into the collection. The collection to which the indices apply Index in the collection Array of indices Clip a string to a given length, starting at a particular offset, returning the clipped string with ellipses representing the removed parts The string to be clipped The maximum permitted length of the result string The point at which to start clipping The clipped string Clip the expected and actual strings in a coordinated fashion, so that they may be displayed together. Shows the position two strings start to differ. Comparison starts at the start index. The expected string The actual string The index in the strings at which comparison should start Boolean indicating whether case should be ignored -1 if no mismatch found, or the index where mismatch found The Numerics class contains common operations on numeric values. Checks the type of the object, returning true if the object is a numeric type. The object to check true if the object is a numeric type Checks the type of the object, returning true if the object is a floating point numeric type. The object to check true if the object is a floating point numeric type Checks the type of the object, returning true if the object is a fixed point numeric type. The object to check true if the object is a fixed point numeric type Test two numeric values for equality, performing the usual numeric conversions and using a provided or default tolerance. If the tolerance provided is Empty, this method may set it to a default tolerance. The expected value The actual value A reference to the tolerance in effect True if the values are equal Compare two numeric values, performing the usual numeric conversions. The expected value The actual value The relationship of the values to each other NUnitComparer encapsulates NUnit's default behavior in comparing two objects. Compares two objects Returns the default NUnitComparer. NUnitEqualityComparer encapsulates NUnit's handling of equality tests between objects. If true, all string comparisons will ignore case If true, arrays will be treated as collections, allowing those of different dimensions to be compared If non-zero, equality comparisons within the specified tolerance will succeed. Comparison object used in comparisons for some constraints. Compares two objects for equality. Helper method to compare two arrays Method to compare two DirectoryInfo objects first directory to compare second directory to compare true if equivalent, false if not Returns the default NUnitEqualityComparer Gets and sets a flag indicating whether case should be ignored in determining equality. Gets and sets a flag indicating that arrays should be compared as collections, without regard to their shape. Gets and sets an external comparer to be used to test for equality. It is applied to members of collections, in place of NUnit's own logic. Gets and sets a tolerance used to compare objects of certin types. Gets the list of failure points for the last Match performed. PathConstraint serves as the abstract base of constraints that operate on paths and provides several helper methods. The expected path used in the constraint The actual path being tested Flag indicating whether a caseInsensitive comparison should be made Construct a PathConstraint for a give expected path The expected path Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Returns true if the expected path and actual path match Returns the string representation of this constraint Canonicalize the provided path The path in standardized form Test whether two paths are the same The first path The second path Indicates whether case should be ignored Test whether one path is under another path The first path - supposed to be the parent path The second path - supposed to be the child path Indicates whether case should be ignored Test whether one path is the same as or under another path The first path - supposed to be the parent path The second path - supposed to be the child path Modifies the current instance to be case-insensitve and returns it. Modifies the current instance to be case-sensitve and returns it. Summary description for SamePathConstraint. Initializes a new instance of the class. The expected path Test whether the constraint is satisfied by a given value The expected path The actual path True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed SubPathConstraint tests that the actual path is under the expected path Initializes a new instance of the class. The expected path Test whether the constraint is satisfied by a given value The expected path The actual path True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed SamePathOrUnderConstraint tests that one path is under another Initializes a new instance of the class. The expected path Test whether the constraint is satisfied by a given value The expected path The actual path True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Predicate constraint wraps a Predicate in a constraint, returning success if the predicate is true. Construct a PredicateConstraint from a predicate Determines whether the predicate succeeds when applied to the actual value. Writes the description to a MessageWriter NotConstraint negates the effect of some other constraint Initializes a new instance of the class. The base constraint to be negated. Test whether the constraint is satisfied by a given value The value to be tested True for if the base constraint fails, false if it succeeds Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The writer on which the actual value is displayed AllItemsConstraint applies another constraint to each item in a collection, succeeding if they all succeed. Construct an AllItemsConstraint on top of an existing constraint Apply the item constraint to each item in the collection, failing if any item fails. Write a description of this constraint to a MessageWriter SomeItemsConstraint applies another constraint to each item in a collection, succeeding if any of them succeeds. Construct a SomeItemsConstraint on top of an existing constraint Apply the item constraint to each item in the collection, succeeding if any item succeeds. Write a description of this constraint to a MessageWriter NoItemConstraint applies another constraint to each item in a collection, failing if any of them succeeds. Construct a SomeItemsConstraint on top of an existing constraint Apply the item constraint to each item in the collection, failing if any item fails. Write a description of this constraint to a MessageWriter PropertyExistsConstraint tests that a named property exists on the object provided through Match. Originally, PropertyConstraint provided this feature in addition to making optional tests on the vaue of the property. The two constraints are now separate. Initializes a new instance of the class. The name of the property. Test whether the property exists for a given object The object to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The writer on which the actual value is displayed Returns the string representation of the constraint. PropertyConstraint extracts a named property and uses its value as the actual value for a chained constraint. Initializes a new instance of the class. The name. The constraint to apply to the property. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed Returns the string representation of the constraint. RangeConstraint tests whethe two values are within a specified range. Initializes a new instance of the class. From. To. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Modifies the constraint to use an IComparer and returns self. Modifies the constraint to use an IComparer<T> and returns self. Modifies the constraint to use a Comparison<T> and returns self. ResolvableConstraintExpression is used to represent a compound constraint being constructed at a point where the last operator may either terminate the expression or may have additional qualifying constraints added to it. It is used, for example, for a Property element or for an Exception element, either of which may be optionally followed by constraints that apply to the property or exception. Create a new instance of ResolvableConstraintExpression Create a new instance of ResolvableConstraintExpression, passing in a pre-populated ConstraintBuilder. Resolve the current expression to a Constraint Appends an And Operator to the expression Appends an Or operator to the expression. ReusableConstraint wraps a resolved constraint so that it may be saved and reused as needed. Construct a ReusableConstraint The constraint or expression to be reused Conversion operator from a normal constraint to a ReusableConstraint. The original constraint to be wrapped as a ReusableConstraint Returns the string representation of the constraint. A string representing the constraint Resolves the ReusableConstraint by returning the constraint that it originally wrapped. A resolved constraint SameAsConstraint tests whether an object is identical to the object passed to its constructor Initializes a new instance of the class. The expected object. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed BinarySerializableConstraint tests whether an object is serializable in binary format. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed Returns the string representation BinarySerializableConstraint tests whether an object is serializable in binary format. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed Returns the string representation of this constraint StringConstraint is the abstract base for constraints that operate on strings. It supports the IgnoreCase modifier for string operations. The expected value Indicates whether tests should be case-insensitive Constructs a StringConstraint given an expected value The expected value Modify the constraint to ignore case in matching. EmptyStringConstraint tests whether a string is empty. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed NullEmptyStringConstraint tests whether a string is either null or empty. Constructs a new NullOrEmptyStringConstraint Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed SubstringConstraint can test whether a string contains the expected substring. Initializes a new instance of the class. The expected. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed StartsWithConstraint can test whether a string starts with an expected substring. Initializes a new instance of the class. The expected string Test whether the constraint is matched by the actual value. This is a template method, which calls the IsMatch method of the derived class. Write the constraint description to a MessageWriter The writer on which the description is displayed EndsWithConstraint can test whether a string ends with an expected substring. Initializes a new instance of the class. The expected string Test whether the constraint is matched by the actual value. This is a template method, which calls the IsMatch method of the derived class. Write the constraint description to a MessageWriter The writer on which the description is displayed RegexConstraint can test whether a string matches the pattern provided. Initializes a new instance of the class. The pattern. Test whether the constraint is satisfied by a given value The value to be tested True for success, false for failure Write the constraint description to a MessageWriter The writer on which the description is displayed ThrowsConstraint is used to test the exception thrown by a delegate by applying a constraint to it. Initializes a new instance of the class, using a constraint to be applied to the exception. A constraint to apply to the caught exception. Executes the code of the delegate and captures any exception. If a non-null base constraint was provided, it applies that constraint to the exception. A delegate representing the code to be tested True if an exception is thrown and the constraint succeeds, otherwise false Converts an ActualValueDelegate to a TestDelegate before calling the primary overload. Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed Returns the string representation of this constraint Get the actual exception thrown - used by Assert.Throws. ThrowsNothingConstraint tests that a delegate does not throw an exception. Test whether the constraint is satisfied by a given value The value to be tested True if no exception is thrown, otherwise false Converts an ActualValueDelegate to a TestDelegate before calling the primary overload. Write the constraint description to a MessageWriter The writer on which the description is displayed Write the actual value for a failing constraint test to a MessageWriter. The default implementation simply writes the raw value of actual, leaving it to the writer to perform any formatting. The writer on which the actual value is displayed Modes in which the tolerance value for a comparison can be interpreted. The tolerance was created with a value, without specifying how the value would be used. This is used to prevent setting the mode more than once and is generally changed to Linear upon execution of the test. The tolerance is used as a numeric range within which two compared values are considered to be equal. Interprets the tolerance as the percentage by which the two compared values my deviate from each other. Compares two values based in their distance in representable numbers. The Tolerance class generalizes the notion of a tolerance within which an equality test succeeds. Normally, it is used with numeric types, but it can be used with any type that supports taking a difference between two objects and comparing that difference to a value. Constructs a linear tolerance of a specdified amount Constructs a tolerance given an amount and ToleranceMode Tests that the current Tolerance is linear with a numeric value, throwing an exception if it is not. Returns an empty Tolerance object, equivalent to specifying an exact match. Gets the ToleranceMode for the current Tolerance Gets the value of the current Tolerance instance. Returns a new tolerance, using the current amount as a percentage. Returns a new tolerance, using the current amount in Ulps. Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of days. Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of hours. Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of minutes. Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of seconds. Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of milliseconds. Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of clock ticks. Returns true if the current tolerance is empty. TypeConstraint is the abstract base for constraints that take a Type as their expected value. The expected Type used by the constraint Construct a TypeConstraint for a given Type Write the actual value for a failing constraint test to a MessageWriter. TypeConstraints override this method to write the name of the type. The writer on which the actual value is displayed ExactTypeConstraint is used to test that an object is of the exact type provided in the constructor Construct an ExactTypeConstraint for a given Type The expected Type. Test that an object is of the exact type specified The actual value. True if the tested object is of the exact type provided, otherwise false. Write the description of this constraint to a MessageWriter The MessageWriter to use InstanceOfTypeConstraint is used to test that an object is of the same type provided or derived from it. Construct an InstanceOfTypeConstraint for the type provided The expected Type Test whether an object is of the specified type or a derived type The object to be tested True if the object is of the provided type or derives from it, otherwise false. Write a description of this constraint to a MessageWriter The MessageWriter to use AssignableFromConstraint is used to test that an object can be assigned from a given Type. Construct an AssignableFromConstraint for the type provided Test whether an object can be assigned from the specified type The object to be tested True if the object can be assigned a value of the expected Type, otherwise false. Write a description of this constraint to a MessageWriter The MessageWriter to use AssignableToConstraint is used to test that an object can be assigned to a given Type. Construct an AssignableToConstraint for the type provided Test whether an object can be assigned to the specified type The object to be tested True if the object can be assigned a value of the expected Type, otherwise false. Write a description of this constraint to a MessageWriter The MessageWriter to use Thrown when an assertion failed. The error message that explains the reason for the exception The error message that explains the reason for the exception The exception that caused the current exception Serialization Constructor Thrown when an assertion failed. The error message that explains the reason for the exception The exception that caused the current exception Serialization Constructor Thrown when a test executes inconclusively. The error message that explains the reason for the exception The error message that explains the reason for the exception The exception that caused the current exception Serialization Constructor Thrown when an assertion failed. The error message that explains the reason for the exception The exception that caused the current exception Serialization Constructor Delegate used by tests that execute code and capture any thrown exception. The Assert class contains a collection of static methods that implement the most common assertions used in NUnit. We don't actually want any instances of this object, but some people like to inherit from it to add other static methods. Hence, the protected constructor disallows any instances of this object. The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function. override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert. Helper for Assert.AreEqual(double expected, double actual, ...) allowing code generation to work consistently. The expected value The actual value The maximum acceptable difference between the the expected and the actual The message to display in case of failure Array of objects to be used in formatting the message Throws a with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit. The message to initialize the with. Arguments to be used in formatting the message Throws a with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit. The message to initialize the with. Throws a with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit. Throws an with the message and arguments that are passed in. This is used by the other Assert functions. The message to initialize the with. Arguments to be used in formatting the message Throws an with the message that is passed in. This is used by the other Assert functions. The message to initialize the with. Throws an . This is used by the other Assert functions. Throws an with the message and arguments that are passed in. This causes the test to be reported as ignored. The message to initialize the with. Arguments to be used in formatting the message Throws an with the message that is passed in. This causes the test to be reported as ignored. The message to initialize the with. Throws an . This causes the test to be reported as ignored. Throws an with the message and arguments that are passed in. This causes the test to be reported as inconclusive. The message to initialize the with. Arguments to be used in formatting the message Throws an with the message that is passed in. This causes the test to be reported as inconclusive. The message to initialize the with. Throws an . This causes the test to be reported as Inconclusive. Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test The message that will be displayed on failure Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint expression to be applied The actual value to test The message that will be displayed on failure Arguments to be used in formatting the message Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint expression to be applied An ActualValueDelegate returning the value to be tested Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint expression to be applied An ActualValueDelegate returning the value to be tested The message that will be displayed on failure Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. An ActualValueDelegate returning the value to be tested A Constraint expression to be applied The message that will be displayed on failure Arguments to be used in formatting the message Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test The message that will be displayed on failure Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test The message that will be displayed on failure Arguments to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display if the condition is false Arguments to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display if the condition is false Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition Asserts that the code represented by a delegate throws an exception that satisfies the constraint provided. A TestDelegate to be executed A ThrowsConstraint used in the test Verifies that a delegate throws a particular exception when called. A constraint to be satisfied by the exception A TestSnippet delegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate throws a particular exception when called. A constraint to be satisfied by the exception A TestSnippet delegate The message that will be displayed on failure Verifies that a delegate throws a particular exception when called. A constraint to be satisfied by the exception A TestSnippet delegate Verifies that a delegate throws a particular exception when called. The exception Type expected A TestSnippet delegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate throws a particular exception when called. The exception Type expected A TestSnippet delegate The message that will be displayed on failure Verifies that a delegate throws a particular exception when called. The exception Type expected A TestSnippet delegate Verifies that a delegate throws a particular exception when called. Type of the expected exception A TestSnippet delegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate throws a particular exception when called. Type of the expected exception A TestSnippet delegate The message that will be displayed on failure Verifies that a delegate throws a particular exception when called. Type of the expected exception A TestSnippet delegate Verifies that a delegate throws an exception when called and returns it. A TestDelegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate throws an exception when called and returns it. A TestDelegate The message that will be displayed on failure Verifies that a delegate throws an exception when called and returns it. A TestDelegate Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it. The expected Exception Type A TestDelegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it. The expected Exception Type A TestDelegate The message that will be displayed on failure Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it. The expected Exception Type A TestDelegate Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it. The expected Exception Type A TestDelegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it. The expected Exception Type A TestDelegate The message that will be displayed on failure Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it. The expected Exception Type A TestDelegate Verifies that a delegate does not throw an exception A TestSnippet delegate The message that will be displayed on failure Arguments to be used in formatting the message Verifies that a delegate does not throw an exception. A TestSnippet delegate The message that will be displayed on failure Verifies that a delegate does not throw an exception. A TestSnippet delegate Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display in case of failure Array of objects to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display in case of failure Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display in case of failure Array of objects to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display in case of failure Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition Asserts that a condition is false. If the condition is true the method throws an . The evaluated condition The message to display in case of failure Array of objects to be used in formatting the message Asserts that a condition is false. If the condition is true the method throws an . The evaluated condition The message to display in case of failure Asserts that a condition is false. If the condition is true the method throws an . The evaluated condition Asserts that a condition is false. If the condition is true the method throws an . The evaluated condition The message to display in case of failure Array of objects to be used in formatting the message Asserts that a condition is false. If the condition is true the method throws an . The evaluated condition The message to display in case of failure Asserts that a condition is false. If the condition is true the method throws an . The evaluated condition Verifies that the object that is passed in is not equal to null If the object is null then an is thrown. The object that is to be tested The message to display in case of failure Array of objects to be used in formatting the message Verifies that the object that is passed in is not equal to null If the object is null then an is thrown. The object that is to be tested The message to display in case of failure Verifies that the object that is passed in is not equal to null If the object is null then an is thrown. The object that is to be tested Verifies that the object that is passed in is not equal to null If the object is null then an is thrown. The object that is to be tested The message to display in case of failure Array of objects to be used in formatting the message Verifies that the object that is passed in is not equal to null If the object is null then an is thrown. The object that is to be tested The message to display in case of failure Verifies that the object that is passed in is not equal to null If the object is null then an is thrown. The object that is to be tested Verifies that the object that is passed in is equal to null If the object is not null then an is thrown. The object that is to be tested The message to display in case of failure Array of objects to be used in formatting the message Verifies that the object that is passed in is equal to null If the object is not null then an is thrown. The object that is to be tested The message to display in case of failure Verifies that the object that is passed in is equal to null If the object is not null then an is thrown. The object that is to be tested Verifies that the object that is passed in is equal to null If the object is not null then an is thrown. The object that is to be tested The message to display in case of failure Array of objects to be used in formatting the message Verifies that the object that is passed in is equal to null If the object is not null then an is thrown. The object that is to be tested The message to display in case of failure Verifies that the object that is passed in is equal to null If the object is not null then an is thrown. The object that is to be tested Verifies that the double that is passed in is an NaN value. If the object is not NaN then an is thrown. The value that is to be tested The message to display in case of failure Array of objects to be used in formatting the message Verifies that the double that is passed in is an NaN value. If the object is not NaN then an is thrown. The value that is to be tested The message to display in case of failure Verifies that the double that is passed in is an NaN value. If the object is not NaN then an is thrown. The value that is to be tested Verifies that the double that is passed in is an NaN value. If the object is not NaN then an is thrown. The value that is to be tested The message to display in case of failure Array of objects to be used in formatting the message Verifies that the double that is passed in is an NaN value. If the object is not NaN then an is thrown. The value that is to be tested The message to display in case of failure Verifies that the double that is passed in is an NaN value. If the object is not NaN then an is thrown. The value that is to be tested Assert that a string is empty - that is equal to string.Empty The string to be tested The message to display in case of failure Array of objects to be used in formatting the message Assert that a string is empty - that is equal to string.Empty The string to be tested The message to display in case of failure Assert that a string is empty - that is equal to string.Empty The string to be tested Assert that an array, list or other collection is empty An array, list or other collection implementing ICollection The message to display in case of failure Array of objects to be used in formatting the message Assert that an array, list or other collection is empty An array, list or other collection implementing ICollection The message to display in case of failure Assert that an array, list or other collection is empty An array, list or other collection implementing ICollection Assert that a string is not empty - that is not equal to string.Empty The string to be tested The message to display in case of failure Array of objects to be used in formatting the message Assert that a string is not empty - that is not equal to string.Empty The string to be tested The message to display in case of failure Assert that a string is not empty - that is not equal to string.Empty The string to be tested Assert that an array, list or other collection is not empty An array, list or other collection implementing ICollection The message to display in case of failure Array of objects to be used in formatting the message Assert that an array, list or other collection is not empty An array, list or other collection implementing ICollection The message to display in case of failure Assert that an array, list or other collection is not empty An array, list or other collection implementing ICollection Assert that a string is either null or equal to string.Empty The string to be tested The message to display in case of failure Array of objects to be used in formatting the message Assert that a string is either null or equal to string.Empty The string to be tested The message to display in case of failure Assert that a string is either null or equal to string.Empty The string to be tested Assert that a string is not null or empty The string to be tested The message to display in case of failure Array of objects to be used in formatting the message Assert that a string is not null or empty The string to be tested The message to display in case of failure Assert that a string is not null or empty The string to be tested Asserts that an object may be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object may be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Asserts that an object may be assigned a value of a given Type. The expected Type. The object under examination Asserts that an object may be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object may be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Asserts that an object may be assigned a value of a given Type. The expected Type. The object under examination Asserts that an object may not be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object may not be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Asserts that an object may not be assigned a value of a given Type. The expected Type. The object under examination Asserts that an object may not be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object may not be assigned a value of a given Type. The expected Type. The object under examination The message to display in case of failure Asserts that an object may not be assigned a value of a given Type. The expected Type. The object under examination Asserts that an object is an instance of a given type. The expected Type The object being examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is an instance of a given type. The expected Type The object being examined The message to display in case of failure Asserts that an object is an instance of a given type. The expected Type The object being examined Asserts that an object is an instance of a given type. The expected Type The object being examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is an instance of a given type. The expected Type The object being examined The message to display in case of failure Asserts that an object is an instance of a given type. The expected Type The object being examined Asserts that an object is an instance of a given type. The expected Type The object being examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is an instance of a given type. The expected Type The object being examined The message to display in case of failure Asserts that an object is an instance of a given type. The expected Type The object being examined Asserts that an object is not an instance of a given type. The expected Type The object being examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is not an instance of a given type. The expected Type The object being examined The message to display in case of failure Asserts that an object is not an instance of a given type. The expected Type The object being examined Asserts that an object is not an instance of a given type. The expected Type The object being examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is not an instance of a given type. The expected Type The object being examined The message to display in case of failure Asserts that an object is not an instance of a given type. The expected Type The object being examined Asserts that an object is not an instance of a given type. The expected Type The object being examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is not an instance of a given type. The expected Type The object being examined The message to display in case of failure Asserts that an object is not an instance of a given type. The expected Type The object being examined Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are equal. If they are not, then an is thrown. The expected value The actual value Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equal then an is thrown. The expected value The actual value The maximum acceptable difference between the the expected and the actual The message to display in case of failure Array of objects to be used in formatting the message Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equal then an is thrown. The expected value The actual value The maximum acceptable difference between the the expected and the actual The message to display in case of failure Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equal then an is thrown. The expected value The actual value The maximum acceptable difference between the the expected and the actual Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equal then an is thrown. The expected value The actual value The maximum acceptable difference between the the expected and the actual The message to display in case of failure Array of objects to be used in formatting the message Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equal then an is thrown. The expected value The actual value The maximum acceptable difference between the the expected and the actual The message to display in case of failure Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equal then an is thrown. The expected value The actual value The maximum acceptable difference between the the expected and the actual Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If they are not equal an is thrown. The value that is expected The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If they are not equal an is thrown. The value that is expected The actual value The message to display in case of failure Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If they are not equal an is thrown. The value that is expected The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value The message to display in case of failure Verifies that two values are not equal. If they are equal, then an is thrown. The expected value The actual value Verifies that two objects are not equal. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If they are equal an is thrown. The value that is expected The actual value The message to display in case of failure Array of objects to be used in formatting the message Verifies that two objects are not equal. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If they are equal an is thrown. The value that is expected The actual value The message to display in case of failure Verifies that two objects are not equal. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types. If they are equal an is thrown. The value that is expected The actual value Asserts that two objects refer to the same object. If they are not the same an is thrown. The expected object The actual object The message to display in case of failure Array of objects to be used in formatting the message Asserts that two objects refer to the same object. If they are not the same an is thrown. The expected object The actual object The message to display in case of failure Asserts that two objects refer to the same object. If they are not the same an is thrown. The expected object The actual object Asserts that two objects do not refer to the same object. If they are the same an is thrown. The expected object The actual object The message to display in case of failure Array of objects to be used in formatting the message Asserts that two objects do not refer to the same object. If they are the same an is thrown. The expected object The actual object The message to display in case of failure Asserts that two objects do not refer to the same object. If they are the same an is thrown. The expected object The actual object Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than the second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less The message to display in case of failure Verifies that the first value is greater than or equal tothe second value. If it is not, then an is thrown. The first value, expected to be greater The second value, expected to be less Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Array of objects to be used in formatting the message Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater The message to display in case of failure Verifies that the first value is less than or equal to the second value. If it is not, then an is thrown. The first value, expected to be less The second value, expected to be greater Asserts that an object is contained in a list. The expected object The list to be examined The message to display in case of failure Array of objects to be used in formatting the message Asserts that an object is contained in a list. The expected object The list to be examined The message to display in case of failure Asserts that an object is contained in a list. The expected object The list to be examined Gets the number of assertions executed so far and resets the counter to zero. AssertionHelper is an optional base class for user tests, allowing the use of shorter names for constraints and asserts and avoiding conflict with the definition of , from which it inherits much of its behavior, in certain mock object frameworks. Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. Works identically to A Constraint to be applied The actual value to test Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. Works identically to A Constraint to be applied The actual value to test The message that will be displayed on failure Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. Works identically to A Constraint to be applied The actual value to test The message that will be displayed on failure Arguments to be used in formatting the message Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint expression to be applied An ActualValueDelegate returning the value to be tested Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint expression to be applied An ActualValueDelegate returning the value to be tested The message that will be displayed on failure Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. An ActualValueDelegate returning the value to be tested A Constraint expression to be applied The message that will be displayed on failure Arguments to be used in formatting the message Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test The message that will be displayed on failure Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure. A Constraint to be applied The actual value to test The message that will be displayed on failure Arguments to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . Works Identically to . The evaluated condition The message to display if the condition is false Arguments to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . Works Identically to . The evaluated condition The message to display if the condition is false Asserts that a condition is true. If the condition is false the method throws an . Works Identically to . The evaluated condition Asserts that the code represented by a delegate throws an exception that satisfies the constraint provided. A TestDelegate to be executed A ThrowsConstraint used in the test Returns a ListMapper based on a collection. The original collection Provides static methods to express the assumptions that must be met for a test to give a meaningful result. If an assumption is not met, the test should produce an inconclusive result. The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function. override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert. Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied The actual value to test Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied The actual value to test The message that will be displayed on failure Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied The actual value to test The message that will be displayed on failure Arguments to be used in formatting the message Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied An ActualValueDelegate returning the value to be tested Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied An ActualValueDelegate returning the value to be tested The message that will be displayed on failure Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. An ActualValueDelegate returning the value to be tested A Constraint expression to be applied The message that will be displayed on failure Arguments to be used in formatting the message Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied The actual value to test Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied The actual value to test The message that will be displayed on failure Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an InconclusiveException on failure. A Constraint expression to be applied The actual value to test The message that will be displayed on failure Arguments to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display if the condition is false Arguments to be used in formatting the message Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition The message to display if the condition is false Asserts that a condition is true. If the condition is false the method throws an . The evaluated condition Asserts that the code represented by a delegate throws an exception that satisfies the constraint provided. A TestDelegate to be executed A ThrowsConstraint used in the test A set of Assert methods operationg on one or more collections The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function. override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert. Asserts that all items contained in collection are of the type specified by expectedType. IEnumerable containing objects to be considered System.Type that all objects in collection must be instances of Asserts that all items contained in collection are of the type specified by expectedType. IEnumerable containing objects to be considered System.Type that all objects in collection must be instances of The message that will be displayed on failure Asserts that all items contained in collection are of the type specified by expectedType. IEnumerable containing objects to be considered System.Type that all objects in collection must be instances of The message that will be displayed on failure Arguments to be used in formatting the message Asserts that all items contained in collection are not equal to null. IEnumerable containing objects to be considered Asserts that all items contained in collection are not equal to null. IEnumerable containing objects to be considered The message that will be displayed on failure Asserts that all items contained in collection are not equal to null. IEnumerable of objects to be considered The message that will be displayed on failure Arguments to be used in formatting the message Ensures that every object contained in collection exists within the collection once and only once. IEnumerable of objects to be considered Ensures that every object contained in collection exists within the collection once and only once. IEnumerable of objects to be considered The message that will be displayed on failure Ensures that every object contained in collection exists within the collection once and only once. IEnumerable of objects to be considered The message that will be displayed on failure Arguments to be used in formatting the message Asserts that expected and actual are exactly equal. The collections must have the same count, and contain the exact same objects in the same order. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered Asserts that expected and actual are exactly equal. The collections must have the same count, and contain the exact same objects in the same order. If comparer is not null then it will be used to compare the objects. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The IComparer to use in comparing objects from each IEnumerable Asserts that expected and actual are exactly equal. The collections must have the same count, and contain the exact same objects in the same order. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Asserts that expected and actual are exactly equal. The collections must have the same count, and contain the exact same objects in the same order. If comparer is not null then it will be used to compare the objects. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The IComparer to use in comparing objects from each IEnumerable The message that will be displayed on failure Asserts that expected and actual are exactly equal. The collections must have the same count, and contain the exact same objects in the same order. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Arguments to be used in formatting the message Asserts that expected and actual are exactly equal. The collections must have the same count, and contain the exact same objects in the same order. If comparer is not null then it will be used to compare the objects. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The IComparer to use in comparing objects from each IEnumerable The message that will be displayed on failure Arguments to be used in formatting the message Asserts that expected and actual are equivalent, containing the same objects but the match may be in any order. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered Asserts that expected and actual are equivalent, containing the same objects but the match may be in any order. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Asserts that expected and actual are equivalent, containing the same objects but the match may be in any order. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Arguments to be used in formatting the message Asserts that expected and actual are not exactly equal. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered Asserts that expected and actual are not exactly equal. If comparer is not null then it will be used to compare the objects. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The IComparer to use in comparing objects from each IEnumerable Asserts that expected and actual are not exactly equal. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Asserts that expected and actual are not exactly equal. If comparer is not null then it will be used to compare the objects. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The IComparer to use in comparing objects from each IEnumerable The message that will be displayed on failure Asserts that expected and actual are not exactly equal. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Arguments to be used in formatting the message Asserts that expected and actual are not exactly equal. If comparer is not null then it will be used to compare the objects. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The IComparer to use in comparing objects from each IEnumerable The message that will be displayed on failure Arguments to be used in formatting the message Asserts that expected and actual are not equivalent. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered Asserts that expected and actual are not equivalent. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Asserts that expected and actual are not equivalent. The first IEnumerable of objects to be considered The second IEnumerable of objects to be considered The message that will be displayed on failure Arguments to be used in formatting the message Asserts that collection contains actual as an item. IEnumerable of objects to be considered Object to be found within collection Asserts that collection contains actual as an item. IEnumerable of objects to be considered Object to be found within collection The message that will be displayed on failure Asserts that collection contains actual as an item. IEnumerable of objects to be considered Object to be found within collection The message that will be displayed on failure Arguments to be used in formatting the message Asserts that collection does not contain actual as an item. IEnumerable of objects to be considered Object that cannot exist within collection Asserts that collection does not contain actual as an item. IEnumerable of objects to be considered Object that cannot exist within collection The message that will be displayed on failure Asserts that collection does not contain actual as an item. IEnumerable of objects to be considered Object that cannot exist within collection The message that will be displayed on failure Arguments to be used in formatting the message Asserts that superset is not a subject of subset. The IEnumerable superset to be considered The IEnumerable subset to be considered Asserts that superset is not a subject of subset. The IEnumerable superset to be considered The IEnumerable subset to be considered The message that will be displayed on failure Asserts that superset is not a subject of subset. The IEnumerable superset to be considered The IEnumerable subset to be considered The message that will be displayed on failure Arguments to be used in formatting the message Asserts that superset is a subset of subset. The IEnumerable superset to be considered The IEnumerable subset to be considered Asserts that superset is a subset of subset. The IEnumerable superset to be considered The IEnumerable subset to be considered The message that will be displayed on failure Asserts that superset is a subset of subset. The IEnumerable superset to be considered The IEnumerable subset to be considered The message that will be displayed on failure Arguments to be used in formatting the message Assert that an array, list or other collection is empty An array, list or other collection implementing IEnumerable The message to be displayed on failure Arguments to be used in formatting the message Assert that an array, list or other collection is empty An array, list or other collection implementing IEnumerable The message to be displayed on failure Assert that an array,list or other collection is empty An array, list or other collection implementing IEnumerable Assert that an array, list or other collection is empty An array, list or other collection implementing IEnumerable The message to be displayed on failure Arguments to be used in formatting the message Assert that an array, list or other collection is empty An array, list or other collection implementing IEnumerable The message to be displayed on failure Assert that an array,list or other collection is empty An array, list or other collection implementing IEnumerable Assert that an array, list or other collection is ordered An array, list or other collection implementing IEnumerable The message to be displayed on failure Arguments to be used in formatting the message Assert that an array, list or other collection is ordered An array, list or other collection implementing IEnumerable The message to be displayed on failure Assert that an array, list or other collection is ordered An array, list or other collection implementing IEnumerable Assert that an array, list or other collection is ordered An array, list or other collection implementing IEnumerable A custom comparer to perform the comparisons The message to be displayed on failure Arguments to be used in formatting the message Assert that an array, list or other collection is ordered An array, list or other collection implementing IEnumerable A custom comparer to perform the comparisons The message to be displayed on failure Assert that an array, list or other collection is ordered An array, list or other collection implementing IEnumerable A custom comparer to perform the comparisons Static helper class used in the constraint-based syntax Creates a new SubstringConstraint The value of the substring A SubstringConstraint Creates a new CollectionContainsConstraint. The item that should be found. A new CollectionContainsConstraint Summary description for DirectoryAssert The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function. override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert. We don't actually want any instances of this object, but some people like to inherit from it to add other static methods. Hence, the protected constructor disallows any instances of this object. Verifies that two directories are equal. Two directories are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A directory containing the value that is expected A directory containing the actual value The message to display if directories are not equal Arguments to be used in formatting the message Verifies that two directories are equal. Two directories are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A directory containing the value that is expected A directory containing the actual value The message to display if directories are not equal Verifies that two directories are equal. Two directories are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A directory containing the value that is expected A directory containing the actual value Verifies that two directories are equal. Two directories are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A directory path string containing the value that is expected A directory path string containing the actual value The message to display if directories are not equal Arguments to be used in formatting the message Verifies that two directories are equal. Two directories are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A directory path string containing the value that is expected A directory path string containing the actual value The message to display if directories are not equal Verifies that two directories are equal. Two directories are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A directory path string containing the value that is expected A directory path string containing the actual value Asserts that two directories are not equal. If they are equal an is thrown. A directory containing the value that is expected A directory containing the actual value The message to display if directories are not equal Arguments to be used in formatting the message Asserts that two directories are not equal. If they are equal an is thrown. A directory containing the value that is expected A directory containing the actual value The message to display if directories are not equal Asserts that two directories are not equal. If they are equal an is thrown. A directory containing the value that is expected A directory containing the actual value Asserts that two directories are not equal. If they are equal an is thrown. A directory path string containing the value that is expected A directory path string containing the actual value The message to display if directories are equal Arguments to be used in formatting the message Asserts that two directories are not equal. If they are equal an is thrown. A directory path string containing the value that is expected A directory path string containing the actual value The message to display if directories are equal Asserts that two directories are not equal. If they are equal an is thrown. A directory path string containing the value that is expected A directory path string containing the actual value Asserts that the directory is empty. If it is not empty an is thrown. A directory to search The message to display if directories are not equal Arguments to be used in formatting the message Asserts that the directory is empty. If it is not empty an is thrown. A directory to search The message to display if directories are not equal Asserts that the directory is empty. If it is not empty an is thrown. A directory to search Asserts that the directory is empty. If it is not empty an is thrown. A directory to search The message to display if directories are not equal Arguments to be used in formatting the message Asserts that the directory is empty. If it is not empty an is thrown. A directory to search The message to display if directories are not equal Asserts that the directory is empty. If it is not empty an is thrown. A directory to search Asserts that the directory is not empty. If it is empty an is thrown. A directory to search The message to display if directories are not equal Arguments to be used in formatting the message Asserts that the directory is not empty. If it is empty an is thrown. A directory to search The message to display if directories are not equal Asserts that the directory is not empty. If it is empty an is thrown. A directory to search Asserts that the directory is not empty. If it is empty an is thrown. A directory to search The message to display if directories are not equal Arguments to be used in formatting the message Asserts that the directory is not empty. If it is empty an is thrown. A directory to search The message to display if directories are not equal Asserts that the directory is not empty. If it is empty an is thrown. A directory to search Asserts that path contains actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Arguments to be used in formatting the message Asserts that path contains actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Asserts that path contains actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory Asserts that path contains actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Arguments to be used in formatting the message Asserts that path contains actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Asserts that path contains actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory Asserts that path does not contain actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Arguments to be used in formatting the message Asserts that path does not contain actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Asserts that path does not contain actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory Asserts that path does not contain actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Arguments to be used in formatting the message Asserts that path does not contain actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory The message to display if directory is not within the path Asserts that path does not contain actual as a subdirectory or an is thrown. A directory to search sub-directory asserted to exist under directory Summary description for FileAssert. The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function. override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert. We don't actually want any instances of this object, but some people like to inherit from it to add other static methods. Hence, the protected constructor disallows any instances of this object. Verifies that two Streams are equal. Two Streams are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. The expected Stream The actual Stream The message to display if Streams are not equal Arguments to be used in formatting the message Verifies that two Streams are equal. Two Streams are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. The expected Stream The actual Stream The message to display if objects are not equal Verifies that two Streams are equal. Two Streams are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. The expected Stream The actual Stream Verifies that two files are equal. Two files are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A file containing the value that is expected A file containing the actual value The message to display if Streams are not equal Arguments to be used in formatting the message Verifies that two files are equal. Two files are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A file containing the value that is expected A file containing the actual value The message to display if objects are not equal Verifies that two files are equal. Two files are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. A file containing the value that is expected A file containing the actual value Verifies that two files are equal. Two files are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. The path to a file containing the value that is expected The path to a file containing the actual value The message to display if Streams are not equal Arguments to be used in formatting the message Verifies that two files are equal. Two files are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. The path to a file containing the value that is expected The path to a file containing the actual value The message to display if objects are not equal Verifies that two files are equal. Two files are considered equal if both are null, or if both have the same value byte for byte. If they are not equal an is thrown. The path to a file containing the value that is expected The path to a file containing the actual value Asserts that two Streams are not equal. If they are equal an is thrown. The expected Stream The actual Stream The message to be displayed when the two Stream are the same. Arguments to be used in formatting the message Asserts that two Streams are not equal. If they are equal an is thrown. The expected Stream The actual Stream The message to be displayed when the Streams are the same. Asserts that two Streams are not equal. If they are equal an is thrown. The expected Stream The actual Stream Asserts that two files are not equal. If they are equal an is thrown. A file containing the value that is expected A file containing the actual value The message to display if Streams are not equal Arguments to be used in formatting the message Asserts that two files are not equal. If they are equal an is thrown. A file containing the value that is expected A file containing the actual value The message to display if objects are not equal Asserts that two files are not equal. If they are equal an is thrown. A file containing the value that is expected A file containing the actual value Asserts that two files are not equal. If they are equal an is thrown. The path to a file containing the value that is expected The path to a file containing the actual value The message to display if Streams are not equal Arguments to be used in formatting the message Asserts that two files are not equal. If they are equal an is thrown. The path to a file containing the value that is expected The path to a file containing the actual value The message to display if objects are not equal Asserts that two files are not equal. If they are equal an is thrown. The path to a file containing the value that is expected The path to a file containing the actual value GlobalSettings is a place for setting default values used by the framework in performing asserts. Default tolerance for floating point equality Helper class with properties and methods that supply a number of constraints used in Asserts. Returns a new PropertyConstraintExpression, which will either test for the existence of the named property on the object being tested or apply any following constraint to that property. Returns a new AttributeConstraint checking for the presence of a particular attribute on an object. Returns a new AttributeConstraint checking for the presence of a particular attribute on an object. Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection. Returns a ConstraintExpression that negates any following constraint. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if at least one of them succeeds. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them fail. Returns a new ConstraintExpression, which will apply the following constraint to the Length property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the Count property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the Message property of the object being tested. Returns a new ConstraintExpression, which will apply the following constraint to the InnerException property of the object being tested. Interface implemented by a user fixture in order to validate any expected exceptions. It is only called for test methods marked with the ExpectedException attribute. Method to handle an expected exception The exception to be handled Helper class with properties and methods that supply a number of constraints used in Asserts. Returns a constraint that tests two items for equality Returns a constraint that tests that two references are the same object Returns a constraint that tests whether the actual value is greater than the suppled argument Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument Returns a constraint that tests whether the actual value is less than the suppled argument Returns a constraint that tests whether the actual value is less than or equal to the suppled argument Returns a constraint that tests whether the actual value is less than or equal to the suppled argument Returns a constraint that tests whether the actual value is of the exact type supplied as an argument. Returns a constraint that tests whether the actual value is of the exact type supplied as an argument. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument. Returns a constraint that tests whether the actual value is a collection containing the same elements as the collection supplied as an argument. Returns a constraint that tests whether the actual value is a subset of the collection supplied as an argument. Returns a constraint that succeeds if the actual value contains the substring supplied as an argument. Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument. Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument. Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument. Returns a constraint that tests whether the path provided is the same as an expected path after canonicalization. Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization. Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization. Returns a constraint that tests whether the actual value falls within a specified range. Returns a ConstraintExpression that negates any following constraint. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed. Returns a constraint that tests for null Returns a constraint that tests for True Returns a constraint that tests for False Returns a constraint that tests for NaN Returns a constraint that tests for empty Returns a constraint that tests whether a collection contains all unique items. Returns a constraint that tests whether an object graph is serializable in binary format. Returns a constraint that tests whether an object graph is serializable in xml format. Returns a constraint that tests whether a collection is ordered The Iz class is a synonym for Is intended for use in VB, which regards Is as a keyword. The List class is a helper class with properties and methods that supply a number of constraints used with lists and collections. List.Map returns a ListMapper, which can be used to map the original collection to another collection. ListMapper is used to transform a collection used as an actual argument producing another collection to be used in the assertion. Construct a ListMapper based on a collection The collection to be transformed Produces a collection containing all the values of a property The collection of property values Randomizer returns a set of random values in a repeatable way, to allow re-running of tests if necessary. Get a randomizer for a particular member, returning one that has already been created if it exists. This ensures that the same values are generated each time the tests are reloaded. Get a randomizer for a particular parameter, returning one that has already been created if it exists. This ensures that the same values are generated each time the tests are reloaded. Construct a randomizer using a random seed Construct a randomizer using a specified seed Return an array of random doubles between 0.0 and 1.0. Return an array of random doubles with values in a specified range. Return an array of random ints with values in a specified range. Get a random seed for use in creating a randomizer. The SpecialValue enum is used to represent TestCase arguments that cannot be used as arguments to an Attribute. Null represents a null value, which cannot be used as an argument to an attriute under .NET 1.x Basic Asserts on strings. The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function. override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert. Asserts that a string is found within another string. The expected string The string to be examined The message to display in case of failure Arguments used in formatting the message Asserts that a string is found within another string. The expected string The string to be examined The message to display in case of failure Asserts that a string is found within another string. The expected string The string to be examined Asserts that a string is not found within another string. The expected string The string to be examined The message to display in case of failure Arguments used in formatting the message Asserts that a string is found within another string. The expected string The string to be examined The message to display in case of failure Asserts that a string is found within another string. The expected string The string to be examined Asserts that a string starts with another string. The expected string The string to be examined The message to display in case of failure Arguments used in formatting the message Asserts that a string starts with another string. The expected string The string to be examined The message to display in case of failure Asserts that a string starts with another string. The expected string The string to be examined Asserts that a string does not start with another string. The expected string The string to be examined The message to display in case of failure Arguments used in formatting the message Asserts that a string does not start with another string. The expected string The string to be examined The message to display in case of failure Asserts that a string does not start with another string. The expected string The string to be examined Asserts that a string ends with another string. The expected string The string to be examined The message to display in case of failure Arguments used in formatting the message Asserts that a string ends with another string. The expected string The string to be examined The message to display in case of failure Asserts that a string ends with another string. The expected string The string to be examined Asserts that a string does not end with another string. The expected string The string to be examined The message to display in case of failure Arguments used in formatting the message Asserts that a string does not end with another string. The expected string The string to be examined The message to display in case of failure Asserts that a string does not end with another string. The expected string The string to be examined Asserts that two strings are equal, without regard to case. The expected string The actual string The message to display in case of failure Arguments used in formatting the message Asserts that two strings are equal, without regard to case. The expected string The actual string The message to display in case of failure Asserts that two strings are equal, without regard to case. The expected string The actual string Asserts that two strings are not equal, without regard to case. The expected string The actual string The message to display in case of failure Arguments used in formatting the message Asserts that two strings are Notequal, without regard to case. The expected string The actual string The message to display in case of failure Asserts that two strings are not equal, without regard to case. The expected string The actual string Asserts that a string matches an expected regular expression pattern. The regex pattern to be matched The actual string The message to display in case of failure Arguments used in formatting the message Asserts that a string matches an expected regular expression pattern. The regex pattern to be matched The actual string The message to display in case of failure Asserts that a string matches an expected regular expression pattern. The regex pattern to be matched The actual string Asserts that a string does not match an expected regular expression pattern. The regex pattern to be used The actual string The message to display in case of failure Arguments used in formatting the message Asserts that a string does not match an expected regular expression pattern. The regex pattern to be used The actual string The message to display in case of failure Asserts that a string does not match an expected regular expression pattern. The regex pattern to be used The actual string The TestCaseData class represents a set of arguments and other parameter info to be used for a parameterized test case. It provides a number of instance modifiers for use in initializing the test case. Note: Instance modifiers are getters that return the same instance after modifying it's state. The argument list to be provided to the test The expected result to be returned The expected exception Type The FullName of the expected exception The name to be used for the test The description of the test A dictionary of properties, used to add information to tests without requiring the class to change. If true, indicates that the test case is to be ignored The reason for ignoring a test case Initializes a new instance of the class. The arguments. Initializes a new instance of the class. The argument. Initializes a new instance of the class. The first argument. The second argument. Initializes a new instance of the class. The first argument. The second argument. The third argument. Sets the expected result for the test The expected result A modified TestCaseData Sets the expected exception type for the test Type of the expected exception. The modified TestCaseData instance Sets the expected exception type for the test FullName of the expected exception. The modified TestCaseData instance Sets the name of the test case The modified TestCaseData instance Sets the description for the test case being constructed. The description. The modified TestCaseData instance. Applies a category to the test Applies a named property to the test Applies a named property to the test Applies a named property to the test Ignores this TestCase. Ignores this TestCase, specifying the reason. The reason. Gets the argument list to be provided to the test Gets the expected result Gets the expected exception Type Gets the FullName of the expected exception Gets the name to be used for the test Gets the description of the test Gets a value indicating whether this is ignored. true if ignored; otherwise, false. Gets the ignore reason. The ignore reason. Gets a list of categories associated with this test. Gets the property dictionary for this test Provide the context information of the current test Constructs a TestContext using the provided context dictionary A context dictionary Get the current test context. This is created as needed. The user may save the context for use within a test, but it should not be used outside the test for which it is created. Gets a TestAdapter representing the currently executing test in this context. Gets a ResultAdapter representing the current result for the test executing in this context. Gets the current directory for this TestContext TestAdapter adapts a Test for consumption by the user test code. Constructs a TestAdapter for this context The context dictionary The name of the test. The FullName of the test The properties of the test. ResultAdapter adapts a TestResult for consumption by the user test code. Construct a ResultAdapter for a context The context holding the result The TestState of current test. This maps to the ResultState used in nunit.core and is subject to change in the future. The TestStatus of current test. This enum will be used in future versions of NUnit and so is to be preferred to the TestState value. The ResultState enum indicates the result of running a test The result is inconclusive The test was not runnable. The test has been skipped. The test has been ignored. The test succeeded The test failed The test encountered an unexpected exception The test was cancelled by the user The TestStatus enum indicates the result of running a test The test was inconclusive The test has skipped The test succeeded The test failed Helper class with static methods used to supply constraints that operate on strings. Returns a constraint that succeeds if the actual value contains the substring supplied as an argument. Returns a constraint that fails if the actual value contains the substring supplied as an argument. Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument. Returns a constraint that fails if the actual value starts with the substring supplied as an argument. Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument. Returns a constraint that fails if the actual value ends with the substring supplied as an argument. Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument. Returns a constraint that fails if the actual value matches the pattern supplied as an argument. Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed. TextMessageWriter writes constraint descriptions and messages in displayable form as a text stream. It tailors the display of individual message components to form the standard message format of NUnit assertion failure messages. Prefix used for the expected value line of a message Prefix used for the actual value line of a message Length of a message prefix Construct a TextMessageWriter Construct a TextMessageWriter, specifying a user message and optional formatting arguments. Method to write single line message with optional args, usually written to precede the general failure message, at a givel indentation level. The indentation level of the message The message to be written Any arguments used in formatting the message Display Expected and Actual lines for a constraint. This is called by MessageWriter's default implementation of WriteMessageTo and provides the generic two-line display. The constraint that failed Display Expected and Actual lines for given values. This method may be called by constraints that need more control over the display of actual and expected values than is provided by the default implementation. The expected value The actual value causing the failure Display Expected and Actual lines for given values, including a tolerance value on the expected line. The expected value The actual value causing the failure The tolerance within which the test was made Display the expected and actual string values on separate lines. If the mismatch parameter is >=0, an additional line is displayed line containing a caret that points to the mismatch point. The expected string value The actual string value The point at which the strings don't match or -1 If true, case is ignored in string comparisons If true, clip the strings to fit the max line length Writes the text for a connector. The connector. Writes the text for a predicate. The predicate. Write the text for a modifier. The modifier. Writes the text for an expected value. The expected value. Writes the text for an actual value. The actual value. Writes the text for a generalized value. The value. Writes the text for a collection value, starting at a particular point, to a max length The collection containing elements to write. The starting point of the elements to write The maximum number of elements to write Write the generic 'Expected' line for a constraint The constraint that failed Write the generic 'Expected' line for a given value The expected value Write the generic 'Expected' line for a given value and tolerance. The expected value The tolerance within which the test was made Write the generic 'Actual' line for a constraint The constraint for which the actual value is to be written Write the generic 'Actual' line for a given value The actual value causing a failure Gets or sets the maximum line length for this writer Helper class with properties and methods that supply constraints that operate on exceptions. Creates a constraint specifying the exact type of exception expected Creates a constraint specifying the exact type of exception expected Creates a constraint specifying the type of exception expected Creates a constraint specifying the type of exception expected Creates a constraint specifying an expected exception Creates a constraint specifying an exception with a given InnerException Creates a constraint specifying an expected TargetInvocationException Creates a constraint specifying an expected TargetInvocationException Creates a constraint specifying an expected TargetInvocationException Creates a constraint specifying that no exception is thrown ================================================ FILE: src/packages/NUnit.2.5.10.11092/license.txt ================================================ Copyright 2002-2008 Charlie Poole Copyright 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov Copyright 2000-2002 Philip A. Craig This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required. Portions Copyright 2002-2008 Charlie Poole or Copyright 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright 2000-2002 Philip A. Craig 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/NUnitTests.VisualState.xml ================================================ [0-1000]D:\Dev\NUnit\nunit-2.5\work\build\net\2.0\release\NUnitTests.nunit [0-1000]D:\Dev\NUnit\nunit-2.5\work\build\net\2.0\release\NUnitTests.nunit false ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/NUnitTests.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/NUnitTests.nunit ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/TestResult.xml ================================================  ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/agent.conf ================================================ 8080 . ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/agent.log.conf ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/launcher.log.conf ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/nunit-agent-x86.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/nunit-agent.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/nunit-console-x86.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/nunit-console.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/nunit-x86.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/nunit.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/pnunit-agent.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/pnunit-launcher.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/runFile.exe.config ================================================ ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/runpnunit.bat ================================================ start pnunit-agent agent.conf pnunit-launcher test.conf ================================================ FILE: src/packages/NUnit.2.5.10.11092/tools/test.conf ================================================ Testing Testing pnunit.tests.dll TestLibraries.Testing.EqualTo19 localhost:8080 ..\server ================================================ FILE: src/packages/repositories.config ================================================  ================================================ FILE: src/simplejson.script.ps1 ================================================ # SimpleJson https://github.com/facebook-csharp-sdk/simple-json # License: MIT License # Version: function ConvertFrom-Json { param( [Switch] $AsPSObject, [Parameter(Mandatory=$true,ValueFromPipeline=$true)][String]$json ) $obj= [SimpleJson.SimpleJson]::DeserializeObject($json) if($AsPSObject) { $obj = ConvertJsonObjectToPsObject($obj) } return $obj } function ConvertTo-Json { param( [object][Parameter(Mandatory=$true,ValueFromPipeline=$true)] $obj ) return [SimpleJson.SimpleJson]::SerializeObject($obj) } function ConvertJsonObjectToPsObject { param( [Object] $obj ) if($obj -eq $null) { return $null } if($obj -is [System.Collections.Generic.IDictionary[string,object]]) { $hash = @{} foreach($kvp in $obj) { $hash[$kvp.Key] = ConvertJsonObjectToPsObject($kvp.Value) } return $hash } if($obj -is [system.collections.generic.list[object]]) { $arr = New-Object object[] $obj.Count for ( $i = 0; $i -lt $obj.count; $i++ ) { $arr[$i] = ConvertJsonObjectToPsObject($obj[$i]) } return $arr } return $obj }