Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Laval <jeremie.laval@gmail.com>2011-01-22 05:13:55 +0300
committerJérémie Laval <jeremie.laval@gmail.com>2011-01-22 05:14:23 +0300
commit3a820d87a61b3bbbea29aefd2458b09558b453b1 (patch)
treea60384146d5fbeef31913aad1ad5ec81b7e5214d /mcs/class/WebMatrix.Data
parentb17767ef1256a9382a6985f671fa3cc80f0fa015 (diff)
Add unit tests for DynamicRecord
Diffstat (limited to 'mcs/class/WebMatrix.Data')
-rw-r--r--mcs/class/WebMatrix.Data/Test/WebMatrix.Data/DynamicRecordTests.cs99
-rw-r--r--mcs/class/WebMatrix.Data/WebMatrix.Data_test.dll.sources2
2 files changed, 101 insertions, 0 deletions
diff --git a/mcs/class/WebMatrix.Data/Test/WebMatrix.Data/DynamicRecordTests.cs b/mcs/class/WebMatrix.Data/Test/WebMatrix.Data/DynamicRecordTests.cs
new file mode 100644
index 00000000000..0a9a177ac6b
--- /dev/null
+++ b/mcs/class/WebMatrix.Data/Test/WebMatrix.Data/DynamicRecordTests.cs
@@ -0,0 +1,99 @@
+//
+// DynamicRecordTests.cs
+//
+// Author:
+// Jérémie "garuma" Laval <jeremie.laval@gmail.com>
+//
+// Copyright (c) 2011 Novell
+//
+// 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.
+
+#if NET_4_0
+
+using System;
+using System.Collections.Generic;
+
+using WebMatrix.Data;
+
+using NUnit.Framework;
+
+namespace MonoTests.WebMatrix.Data
+{
+ [TestFixtureAttribute]
+ public class DynamicRecordTests
+ {
+ DynamicRecord record;
+
+ [SetUp]
+ public void Setup ()
+ {
+ var fields = new Dictionary<string, object> () {
+ { "foo", 1 },
+ { "bar", 4.1f },
+ { "foobar", "foobar" }
+ };
+ record = new DynamicRecord (fields);
+ }
+
+ [Test]
+ public void ColumnsTest ()
+ {
+ var columns = record.Columns;
+ Assert.AreEqual (3, columns.Count);
+
+ Assert.AreEqual ("foo", columns[0]);
+ Assert.AreEqual ("bar", columns[1]);
+ Assert.AreEqual ("foobar", columns[2]);
+ }
+
+ [Test]
+ public void AccessByNameTest ()
+ {
+ Assert.AreEqual (1, record["foo"]);
+ Assert.AreEqual (4.1f, record["bar"]);
+ Assert.AreEqual ("foobar", record["foobar"]);
+ }
+
+ [Test]
+ public void AccessByIndexTest ()
+ {
+ Assert.AreEqual (1, record[0]);
+ Assert.AreEqual (4.1f, record[1]);
+ Assert.AreEqual ("foobar", record[2]);
+ }
+
+ [Test]
+ public void AccesByDynamicTest ()
+ {
+ dynamic r = record;
+
+ Assert.AreEqual (1, r.foo);
+ Assert.AreEqual (4.1f, r.bar);
+ Assert.AreEqual ("foobar", r.foobar);
+ }
+
+ [Test]
+ public void GetDynamicMemberNamesTest ()
+ {
+ var expected = new string[] { "foo", "bar", "foobar" };
+ CollectionAssert.AreEquivalent (expected, record.GetDynamicMemberNames ());
+ }
+ }
+}
+#endif \ No newline at end of file
diff --git a/mcs/class/WebMatrix.Data/WebMatrix.Data_test.dll.sources b/mcs/class/WebMatrix.Data/WebMatrix.Data_test.dll.sources
index 88c61bcab59..017d36adb25 100644
--- a/mcs/class/WebMatrix.Data/WebMatrix.Data_test.dll.sources
+++ b/mcs/class/WebMatrix.Data/WebMatrix.Data_test.dll.sources
@@ -1 +1,3 @@
WebMatrix.Data/ConnectionEventArgsTests.cs
+WebMatrix.Data/DynamicRecordTests.cs
+../WebMatrix.Data/DynamicRecord.cs