forked from mongodb/mongo-csharp-driver
/
HashtableTests.cs
107 lines (89 loc) · 3 KB
/
HashtableTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management.Automation;
using MongoDB.Bson;
using MongoDB.Driver;
using NUnit.Framework;
namespace MonogoDB.DriverUnitTestsPosh.HashtableCasts
{
[TestFixture]
public sealed class HashtableTests : PoshTestsBase
{
const string scriptFormat = @"
[{0}] @{{
Name = 'Justin Dearing'
EmailAddresses = 'zippy1981@gmail.com','justin@mongodb.org'
PhoneNumber = '718-555-1212'
}};
";
private void TestHashTableCast(Type type)
{
var results = RunScript(string.Format(scriptFormat, type.FullName));
Assert.AreEqual(3, results.Count, "Expected three result sets");
Assert.IsTrue(results.Contains(new PSObject(new BsonElement("Name", "Justin Dearing"))));
Assert.IsTrue(results.Contains(new PSObject(new BsonElement("PhoneNumber", "718-555-1212"))));
//Now do it for [ordered]@{ . . . }
results = RunScript(string.Format(scriptFormat, type.FullName + "][ordered"));
Assert.AreEqual(3, results.Count, "Expected three result sets");
Assert.IsTrue(results.Contains(new PSObject(new BsonElement("Name", "Justin Dearing"))));
Assert.IsTrue(results.Contains(new PSObject(new BsonElement("PhoneNumber", "718-555-1212"))));
}
[Test]
public void TestCollectionOptionsDocument()
{
TestHashTableCast(typeof(CollectionOptionsDocument));
}
[Test]
public void TestCommandDocument()
{
TestHashTableCast(typeof(CommandDocument));
}
[Test]
public void TestFieldsDocument()
{
TestHashTableCast(typeof(FieldsDocument));
}
[Test]
public void TestGeoHaystackSearchOptionsDocument()
{
TestHashTableCast(typeof(GeoHaystackSearchOptionsDocument));
}
[Test]
public void TestGeoNearOptionsDocument()
{
TestHashTableCast(typeof(GeoNearOptionsDocument));
}
[Test]
public void TestGroupByDocument()
{
TestHashTableCast(typeof(GroupByDocument));
}
[Test]
public void TestIndexKeysDocument()
{
TestHashTableCast(typeof(IndexKeysDocument));
}
[Test]
public void TestIndexOptionsDocument()
{
TestHashTableCast(typeof(IndexOptionsDocument));
}
[Test]
public void TestMapReduceOptionsDocument()
{
TestHashTableCast(typeof(MapReduceOptionsDocument));
}
[Test]
public void TestQueryDocument()
{
TestHashTableCast(typeof(QueryDocument));
}
[Test]
public void TestScopeDocument()
{
TestHashTableCast(typeof(ScopeDocument));
}
}
}