Permalink
Browse files

Added unit test for $or support.

  • Loading branch information...
1 parent f355154 commit ca21152d7b5bb62a0177d010534a1ba359e15142 @atheken committed Aug 11, 2010
Showing with 26 additions and 6 deletions.
  1. +22 −2 NoRM.Tests/CollectionFindTests/WhereQualifierTests.cs
  2. +4 −4 NoRM/Commands/Qualifiers/Q.cs
@@ -27,19 +27,39 @@ public void Dispose()
}
[Fact]
- public void MultiQualifier()
+ public void MultiQualifierAnd()
{
_collection.Insert(new TestClass { AInteger = 78 },
new TestClass { AInteger = 79 },
new TestClass { AInteger = 80 },
new TestClass { AInteger = 81 });
var result = _collection.Find(new { AInteger = Q.LessThan(81).And(Q.GreaterThan(78)) }).ToArray();
- Assert.Equal(2,result.Length);
+ Assert.Equal(2, result.Length);
Assert.Equal(79, result[0].AInteger);
Assert.Equal(80, result[1].AInteger);
}
+ [Fact]
+ public void MultiQualifieOr()
+ {
+ _collection.Insert(
+ new TestClass { AInteger = 78 },
+ new TestClass { AInteger = 79 },
+ new TestClass { AInteger = 80 },
+ new TestClass { AInteger = 81 });
+
+
+
+ var result = _collection.Find(
+ Q.Or(new { AInteger = Q.LessOrEqual(78) },
+ new { AInteger = Q.GreaterOrEqual(81) })
+ ).ToArray();
+ Assert.Equal(2, result.Length);
+ Assert.Equal(78, result[0].AInteger);
+ Assert.Equal(81, result[1].AInteger);
+ }
+
[Fact]
public void WhereExpressionShouldWorkWithFlyweight()
{
@@ -60,7 +60,7 @@ public static OrQualifier Or(params object[] orGroups)
return new OrQualifier(orGroups);
}
-
+
/// <summary>
/// Produces an "$or" qualifier where each of the groups is a set of criteria.
/// </summary>
@@ -85,9 +85,9 @@ public static SliceQualifier Slice(int index)
/// </summary>
/// <param name="left">The first index for the slice.</param>
/// <param name="right">The second index for the slice.</param>
- public static SliceQualifier Slice(int left,int right)
+ public static SliceQualifier Slice(int left, int right)
{
- return new SliceQualifier(left,right);
+ return new SliceQualifier(left, right);
}
/// <summary>
@@ -119,7 +119,7 @@ public static LessThanQualifier LessThan(object value)
{
return new LessThanQualifier(value);
}
-
+
/// <summary>
/// Builds a $lte qualifier for the search.
/// </summary>

0 comments on commit ca21152

Please sign in to comment.