This repository has been archived by the owner on Dec 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
TestOp.cs
150 lines (115 loc) · 3.25 KB
/
TestOp.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using MongoDB.Bson;
using NUnit.Framework;
namespace MongoDB.UnitTests
{
[TestFixture]
public class TestOp
{
[Test]
public void ConjunctionsWith2Operators()
{
var op = Op.GreaterThan(10) & Op.LessThan(20);
Assert.AreEqual(10, op["$gt"]);
Assert.AreEqual(20, op["$lt"]);
}
[Test]
public void ConjunctionsWith3Operators()
{
var op = Op.GreaterThan(10) & Op.LessThan(20) & Op.Mod(3, 1);
Assert.AreEqual(10, op["$gt"]);
Assert.AreEqual(20, op["$lt"]);
Assert.AreEqual(new [] { 3, 1 }, op["$mod"]);
}
[Test]
public void Negation()
{
var op = !Op.GreaterThan(10);
var negated = (Op)op["$not"];
Assert.AreEqual(10, negated["$gt"]);
}
[Test]
public void GreaterThan()
{
var op = Op.GreaterThan(10);
Assert.AreEqual(10, op["$gt"]);
}
[Test]
public void GreaterThanOrEqual()
{
var op = Op.GreaterThanOrEqual(10);
Assert.AreEqual(10, op["$gte"]);
}
[Test]
public void LessThan()
{
var op = Op.LessThan(10);
Assert.AreEqual(10, op["$lt"]);
}
[Test]
public void LessThanOrEqual()
{
var op = Op.LessThanOrEqual(10);
Assert.AreEqual(10, op["$lte"]);
}
[Test]
public void NotEqual()
{
var op = Op.NotEqual(10);
Assert.AreEqual(10, op["$ne"]);
}
[Test]
public void In()
{
var op = Op.In(10,11,12);
Assert.AreEqual(new[] { 10, 11, 12 }, op["$in"]);
}
[Test]
public void NotIn()
{
var op = Op.NotIn(10, 11, 12);
Assert.AreEqual(new[] { 10, 11, 12 }, op["$nin"]);
}
[Test]
public void All()
{
var op = Op.All(10, 11, 12);
Assert.AreEqual(new[] { 10, 11, 12 }, op["$all"]);
}
[Test]
public void Mod()
{
var op = Op.Mod(10, 1);
Assert.AreEqual(new[] { 10, 1 }, op["$mod"]);
}
[Test]
public void Size()
{
var op = Op.Size(10);
Assert.AreEqual(10, op["$size"]);
}
[Test]
public void Exists()
{
var op = Op.Exists();
Assert.AreEqual(true, op["$exists"]);
}
[Test]
public void NotExists()
{
var op = Op.NotExists();
Assert.AreEqual(false, op["$exists"]);
}
[Test]
public void Type()
{
var op = Op.Type(BsonDataType.Boolean);
Assert.AreEqual((int)BsonDataType.Boolean, op["$type"]);
}
[Test]
public void Where()
{
var op = Op.Where("return this.a == 3 || this.b == 4;");
Assert.AreEqual(new Code("return this.a == 3 || this.b == 4;"),op["$where"]);
}
}
}