Permalink
Browse files

Added a session object with generic type parameter support. Linq quer…

…y syntactic sugar.
  • Loading branch information...
TylerBrinks committed Mar 1, 2010
1 parent 81fa780 commit 8ad8037e6d2d62c854e62ef84b6bb63b6593a4b3
@@ -0,0 +1,48 @@
+
+
+using System.Linq;
+using NoRM.Linq;
+using Xunit;
+
+namespace NoRM.Tests
+{
+ public class MongoTypedSessionTests
+ {
+ [Fact]
+ public void TypedSessionSupportsIQueryableCollections()
+ {
+ using (var session = new MongoTypedSession<Product>("mongodb://localhost/NoRMTests?pooling=false&strict=false"))
+ {
+ session.Drop<Product>();
+ session.Add(new Product { Name = "Test2X", Price = 10 });
+ session.Add(new Product { Name = "Test3", Price = 33 });
+ session.Add(new Product { Name = "XTest4", Price = 22 });
+
+ var products = session.Query.Where(x => x.Name.StartsWith("X") || x.Name.EndsWith("X")).ToList();
+ Assert.Equal(2, products.Count);
+ }
+ }
+ [Fact]
+ public void TypedSessionQueriesInnerListTypes()
+ {
+ using (var session = new MongoTypedSession<Product>("mongodb://localhost/NoRMTests?pooling=false&strict=false"))
+ {
+ session.Drop<Product>();
+ session.Drop<NotAProduct>();
+ session.Add(new NotAProduct { Name = "Test1X" });
+ session.Add(new Product { Name = "Test2X", Price = 10 });
+ session.Add(new Product { Name = "Test3", Price = 33 });
+ session.Add(new Product { Name = "XTest4", Price = 22 });
+
+ var products = session.Query.Where(x => x.Name.StartsWith("X") || x.Name.EndsWith("X")).ToList();
+ Assert.Equal(2, products.Count);
+ }
+ }
+ }
+
+ public class NotAProduct
+ {
+ public ObjectId Id { get; set; }
+ public string Name { get; set; }
+ }
+}
@@ -58,6 +58,7 @@
<Compile Include="ConnectionsTests\NormalConnectionProviderAuthenticationTests.cs" />
<Compile Include="ConnectionsTests\NormalConnectionProviderTests.cs" />
<Compile Include="ConnectionsTests\PooledConnectionProviderTests.cs" />
+ <Compile Include="ConnectionsTests\QueuedConnectionProviderTests.cs" />
<Compile Include="LinqDeepGraph.cs" />
<Compile Include="LinqTests.cs" />
<Compile Include="MongoAdminTests.cs" />
@@ -67,6 +68,7 @@
<Compile Include="MongoFixture.cs" />
<Compile Include="MongoSearchQualifierTests.cs" />
<Compile Include="MongoTests.cs" />
+ <Compile Include="MongoTypedSessionTests.cs" />
<Compile Include="ObjectIdTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestClasses.cs" />
Oops, something went wrong.

0 comments on commit 8ad8037

Please sign in to comment.