Skip to content
Browse files

Line Endings...boooo

  • Loading branch information...
1 parent 979afd4 commit 721515e5705e99e3b0d74efcc8054fdcb0f3d612 @schotime schotime committed Jul 8, 2010
Showing with 225 additions and 225 deletions.
  1. +51 −51 NoRM.Tests/CollectionFindTests/QueryTests.cs
  2. +79 −79 NoRM.Tests/LinqTests/LinqTests.cs
  3. +95 −95 NoRM.Tests/MongoCollectionTests.cs
View
102 NoRM.Tests/CollectionFindTests/QueryTests.cs
@@ -5,7 +5,7 @@
using Xunit;
using Norm.Collections;
using System.Text.RegularExpressions;
-using System.Collections.Generic;
+using System.Collections.Generic;
using Norm.Commands.Modifiers;
namespace Norm.Tests
@@ -382,55 +382,55 @@ public void DistinctOnComplexProperty()
var results = _collection.Distinct<Address>("Address");
Assert.Equal(3, results.Count());
- }
-
- [Fact]
- public void FindAndModify()
- {
- _collection.Insert(new Person { Name = "Joe Cool", Age = 10 });
-
- var update = new Expando();
- update["$inc"] = new { Age = 1 };
-
- var result = _collection.FindAndModify(new { Name = "Joe Cool" }, update);
- Assert.Equal(10, result.Age);
-
- var result2 = _collection.Find(new { Name = "Joe Cool" }).FirstOrDefault();
- Assert.Equal(11, result2.Age);
- }
-
- [Fact]
- public void FindAndModifyWithSort()
- {
- _collection.Insert(new Person { Name = "Joe Cool", Age = 10 });
- _collection.Insert(new Person { Name = "Joe Cool", Age = 15 });
-
- var update = new Expando();
- update["$inc"] = new { Age = 1 };
-
- var result = _collection.FindAndModify(new { Name = "Joe Cool" }, update, new { Age = Norm.OrderBy.Descending });
- Assert.Equal(15, result.Age);
-
- var result2 = _collection.Find(new { Name = "Joe Cool" }).OrderByDescending(x=>x.Age).ToList();
- Assert.Equal(16, result2[0].Age);
- Assert.Equal(10, result2[1].Age);
-
- }
-
- [Fact]
- public void FindAndModifyReturnsNullWhenQueryNotFound()
- {
- _collection.Insert(new Person { Name = "Joe Cool", Age = 10 });
- _collection.Insert(new Person { Name = "Joe Cool", Age = 15 });
-
- var update = new Expando();
- update["$inc"] = new { Age = 1 };
-
- var result = _collection.FindAndModify(new { Name = "Joe Cool1" }, update, new { Age = Norm.OrderBy.Descending });
- Assert.Null(result);
-
- var result2 = _collection.Find(new { Age = 15 }).ToList();
- Assert.Equal(1, result2.Count);
- }
+ }
+
+ [Fact]
+ public void FindAndModify()
+ {
+ _collection.Insert(new Person { Name = "Joe Cool", Age = 10 });
+
+ var update = new Expando();
+ update["$inc"] = new { Age = 1 };
+
+ var result = _collection.FindAndModify(new { Name = "Joe Cool" }, update);
+ Assert.Equal(10, result.Age);
+
+ var result2 = _collection.Find(new { Name = "Joe Cool" }).FirstOrDefault();
+ Assert.Equal(11, result2.Age);
+ }
+
+ [Fact]
+ public void FindAndModifyWithSort()
+ {
+ _collection.Insert(new Person { Name = "Joe Cool", Age = 10 });
+ _collection.Insert(new Person { Name = "Joe Cool", Age = 15 });
+
+ var update = new Expando();
+ update["$inc"] = new { Age = 1 };
+
+ var result = _collection.FindAndModify(new { Name = "Joe Cool" }, update, new { Age = Norm.OrderBy.Descending });
+ Assert.Equal(15, result.Age);
+
+ var result2 = _collection.Find(new { Name = "Joe Cool" }).OrderByDescending(x=>x.Age).ToList();
+ Assert.Equal(16, result2[0].Age);
+ Assert.Equal(10, result2[1].Age);
+
+ }
+
+ [Fact]
+ public void FindAndModifyReturnsNullWhenQueryNotFound()
+ {
+ _collection.Insert(new Person { Name = "Joe Cool", Age = 10 });
+ _collection.Insert(new Person { Name = "Joe Cool", Age = 15 });
+
+ var update = new Expando();
+ update["$inc"] = new { Age = 1 };
+
+ var result = _collection.FindAndModify(new { Name = "Joe Cool1" }, update, new { Age = Norm.OrderBy.Descending });
+ Assert.Null(result);
+
+ var result2 = _collection.Find(new { Age = 15 }).ToList();
+ Assert.Equal(1, result2.Count);
+ }
}
}
View
158 NoRM.Tests/LinqTests/LinqTests.cs
@@ -40,38 +40,38 @@ public void ProviderSupportsProjection()
}
}
- [Fact]
- public void ProviderSupportsSophisticatedProjection()
- {
- using (var db = Mongo.Create(TestHelper.ConnectionString()))
- {
- var coll = db.GetCollection<TestProduct>();
-
- coll.Insert(new TestProduct { Available = DateTime.Now }, new TestProduct { Available = DateTime.Now });
-
- var results = db.GetCollection<TestProduct>().AsQueryable()
- .Select(y => new { Avail = y.Available, Id = y._id }).ToArray();
-
- Assert.Equal(2, results.Length);
- Assert.Equal((new { Avail = DateTime.Now, Id = ObjectId.Empty }).GetType(),
- results[0].GetType());
- }
+ [Fact]
+ public void ProviderSupportsSophisticatedProjection()
+ {
+ using (var db = Mongo.Create(TestHelper.ConnectionString()))
+ {
+ var coll = db.GetCollection<TestProduct>();
+
+ coll.Insert(new TestProduct { Available = DateTime.Now }, new TestProduct { Available = DateTime.Now });
+
+ var results = db.GetCollection<TestProduct>().AsQueryable()
+ .Select(y => new { Avail = y.Available, Id = y._id }).ToArray();
+
+ Assert.Equal(2, results.Length);
+ Assert.Equal((new { Avail = DateTime.Now, Id = ObjectId.Empty }).GetType(),
+ results[0].GetType());
+ }
}
[Fact]
public void ProviderSupportsSophisticatedProjectionWithConcreteType()
{
using (var db = Mongo.Create(TestHelper.ConnectionString()))
{
- var coll = db.GetCollection<TestProduct>();
-
+ var coll = db.GetCollection<TestProduct>();
+
coll.Insert(new TestProduct { Name = "AAA", Price = 10 }, new TestProduct { Name = "BBB", Price = 20 });
var results = db.GetCollection<TestProduct>().AsQueryable()
.Select(y => new TestProductSummary { _id = y._id, Name = y.Name, Price = y.Price }).ToArray();
Assert.Equal(2, results.Length);
- Assert.Equal((new TestProductSummary()).GetType(), results[0].GetType());
+ Assert.Equal((new TestProductSummary()).GetType(), results[0].GetType());
}
}
@@ -181,8 +181,8 @@ public void ProviderSupportsProjectionInAnyOrderWithWhereFirst()
Assert.Equal(false, stucture.IsComplex);
}
- }
-
+ }
+
[Fact]
public void LinqQueriesShouldSupportExternalParameters()
{
@@ -1754,64 +1754,64 @@ public void CanQueryWithinEmbeddedArrayUsingAny()
Assert.Equal("Second", found.Title);
Assert.Equal(false, queryable.QueryStructure().IsComplex);
}
- }
-
- [Fact]
- public void CanQueryWithinEmbeddedArrayUsingAnyWithBool()
- {
- using (var session = new Session())
- {
- var post1 = new Post
- {
- Title = "First",
- Comments = new List<Comment> {
- new Comment { Text = "comment1", IsOld = false },
- new Comment { Text = "comment2", IsOld = false }
- }
- };
- var post2 = new Post
- {
- Title = "Second",
- Comments = new List<Comment> {
- new Comment { Text = "commentA", Name = "name1", IsOld = true },
- new Comment { Text = "commentB", Name = "name2", IsOld = false }
- }
- };
-
- session.Add(post1);
- session.Add(post2);
-
- var queryable = session.Posts;
- var found = queryable.Where(p => p.Comments.Any(x => x.IsOld)).ToList();
-
- Assert.Equal(1, found.Count);
- Assert.Equal("Second", found[0].Title);
-
- Assert.Equal(false, queryable.QueryStructure().IsComplex);
- }
- }
-
- [Fact]
- public void CanQueryWithinEmbeddedArrayUsingAnyWithBoolNegated()
- {
- using (var session = new Session())
- {
- var tf = false;
-
- var post1 = new Post { Title = "First", Comments = new List<Comment> { new Comment { Text = "comment1", IsOld = false }, new Comment { Text = "comment2", IsOld = false } } };
- var post2 = new Post { Title = "Second", Comments = new List<Comment> { new Comment { Text = "commentA", Name = "name1", IsOld = true }, new Comment { Text = "commentB", Name = "name2", IsOld = true } } };
-
- session.Add(post1);
- session.Add(post2);
-
- var queryable = session.Posts;
- var found = queryable.Where(p => p.Comments.Any(x => x.IsOld == tf)).ToList();
-
- Assert.Equal(1, found.Count);
- Assert.Equal("First", found[0].Title);
-
- Assert.Equal(false, queryable.QueryStructure().IsComplex);
- }
+ }
+
+ [Fact]
+ public void CanQueryWithinEmbeddedArrayUsingAnyWithBool()
+ {
+ using (var session = new Session())
+ {
+ var post1 = new Post
+ {
+ Title = "First",
+ Comments = new List<Comment> {
+ new Comment { Text = "comment1", IsOld = false },
+ new Comment { Text = "comment2", IsOld = false }
+ }
+ };
+ var post2 = new Post
+ {
+ Title = "Second",
+ Comments = new List<Comment> {
+ new Comment { Text = "commentA", Name = "name1", IsOld = true },
+ new Comment { Text = "commentB", Name = "name2", IsOld = false }
+ }
+ };
+
+ session.Add(post1);
+ session.Add(post2);
+
+ var queryable = session.Posts;
+ var found = queryable.Where(p => p.Comments.Any(x => x.IsOld)).ToList();
+
+ Assert.Equal(1, found.Count);
+ Assert.Equal("Second", found[0].Title);
+
+ Assert.Equal(false, queryable.QueryStructure().IsComplex);
+ }
+ }
+
+ [Fact]
+ public void CanQueryWithinEmbeddedArrayUsingAnyWithBoolNegated()
+ {
+ using (var session = new Session())
+ {
+ var tf = false;
+
+ var post1 = new Post { Title = "First", Comments = new List<Comment> { new Comment { Text = "comment1", IsOld = false }, new Comment { Text = "comment2", IsOld = false } } };
+ var post2 = new Post { Title = "Second", Comments = new List<Comment> { new Comment { Text = "commentA", Name = "name1", IsOld = true }, new Comment { Text = "commentB", Name = "name2", IsOld = true } } };
+
+ session.Add(post1);
+ session.Add(post2);
+
+ var queryable = session.Posts;
+ var found = queryable.Where(p => p.Comments.Any(x => x.IsOld == tf)).ToList();
+
+ Assert.Equal(1, found.Count);
+ Assert.Equal("First", found[0].Title);
+
+ Assert.Equal(false, queryable.QueryStructure().IsComplex);
+ }
}
[Fact]
View
190 NoRM.Tests/MongoCollectionTests.cs
@@ -19,7 +19,7 @@ public MongoCollectionTests()
using (var mongo = Mongo.Create(TestHelper.ConnectionString("strict=false")))
{
- mongo.Database.DropCollection("Fake");
+ mongo.Database.DropCollection("Fake");
mongo.Database.DropCollection("Faker");
}
}
@@ -332,100 +332,100 @@ public void InsertingMultipleNewEntityWithObjectIdKeyGeneratesAKey()
Assert.NotNull(product2._id);
Assert.NotEqual(ObjectId.Empty, product2._id);
}
- }
-
- [Fact]
- public void InsertingANewEntityGeneratingTheIntKeyFirst()
- {
- using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
- {
- var collection = mongo.GetCollection<TestIntGeneration>("Fake");
-
- var identity = (int)collection.GenerateId();
- var testint = new TestIntGeneration { _id = identity, Name = "TestMe" };
- collection.Insert(testint);
-
- var result = collection.FindOne(new { _id = testint._id });
-
- Assert.NotNull(testint._id);
- Assert.Equal(result.Name, "TestMe");
- }
- }
-
- [Fact]
- public void InsertingANewEntityWithNullableIntGeneratesAKey()
- {
- using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
- {
- var testint = new TestIntGeneration { _id = null };
- mongo.GetCollection<TestIntGeneration>("Fake").Insert(testint);
-
- Assert.NotNull(testint._id);
- Assert.NotEqual(0, testint._id.Value);
- }
- }
-
- [Fact]
- public void InsertingANewEntityWithNullableIntGeneratesAKeyComplex()
- {
- using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
- {
- var idents = new List<int>();
- for (int i = 0; i < 15; i++)
- {
- var testint = new TestIntGeneration { _id = null };
- mongo.GetCollection<TestIntGeneration>("Fake").Insert(testint);
- idents.Add(testint._id.Value);
- }
-
- var list = mongo.GetCollection<TestIntGeneration>("Fake").Find(new { _id = Q.In(idents.ToArray()) });
-
- foreach (var item in list)
- {
- Assert.True(idents.Contains(item._id.Value));
- }
-
- Assert.Equal(idents.Distinct().Count(), list.Select(x => x._id.Value).Distinct().Count());
- }
- }
-
- [Fact]
- public void InsertingANewEntityWithNullableIntGeneratesAKeyComplexWith2Collections()
- {
- using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
- {
- var idents = new List<int>();
- for (int i = 0; i < 15; i++)
- {
- var testint = new TestIntGeneration { _id = null };
- mongo.GetCollection<TestIntGeneration>("Fake").Insert(testint);
- idents.Add(testint._id.Value);
- }
-
- var idents2 = new List<int>();
- for (int i = 0; i < 15; i++)
- {
- var testint = new TestIntGeneration { _id = null };
- mongo.GetCollection<TestIntGeneration>("Faker").Insert(testint);
- idents2.Add(testint._id.Value);
- }
-
- var list = mongo.GetCollection<TestIntGeneration>("Fake").Find(new { _id = Q.In(idents.ToArray()) });
- var list2 = mongo.GetCollection<TestIntGeneration>("Faker").Find(new { _id = Q.In(idents2.ToArray()) });
-
- foreach (var item in list)
- {
- Assert.True(idents.Contains(item._id.Value));
- }
-
- foreach (var item in list2)
- {
- Assert.True(idents2.Contains(item._id.Value));
- }
-
- Assert.Equal(idents.Distinct().Count(), list.Select(x => x._id.Value).Distinct().Count());
- Assert.Equal(idents2.Distinct().Count(), list2.Select(x => x._id.Value).Distinct().Count());
- }
+ }
+
+ [Fact]
+ public void InsertingANewEntityGeneratingTheIntKeyFirst()
+ {
+ using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
+ {
+ var collection = mongo.GetCollection<TestIntGeneration>("Fake");
+
+ var identity = (int)collection.GenerateId();
+ var testint = new TestIntGeneration { _id = identity, Name = "TestMe" };
+ collection.Insert(testint);
+
+ var result = collection.FindOne(new { _id = testint._id });
+
+ Assert.NotNull(testint._id);
+ Assert.Equal(result.Name, "TestMe");
+ }
+ }
+
+ [Fact]
+ public void InsertingANewEntityWithNullableIntGeneratesAKey()
+ {
+ using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
+ {
+ var testint = new TestIntGeneration { _id = null };
+ mongo.GetCollection<TestIntGeneration>("Fake").Insert(testint);
+
+ Assert.NotNull(testint._id);
+ Assert.NotEqual(0, testint._id.Value);
+ }
+ }
+
+ [Fact]
+ public void InsertingANewEntityWithNullableIntGeneratesAKeyComplex()
+ {
+ using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
+ {
+ var idents = new List<int>();
+ for (int i = 0; i < 15; i++)
+ {
+ var testint = new TestIntGeneration { _id = null };
+ mongo.GetCollection<TestIntGeneration>("Fake").Insert(testint);
+ idents.Add(testint._id.Value);
+ }
+
+ var list = mongo.GetCollection<TestIntGeneration>("Fake").Find(new { _id = Q.In(idents.ToArray()) });
+
+ foreach (var item in list)
+ {
+ Assert.True(idents.Contains(item._id.Value));
+ }
+
+ Assert.Equal(idents.Distinct().Count(), list.Select(x => x._id.Value).Distinct().Count());
+ }
+ }
+
+ [Fact]
+ public void InsertingANewEntityWithNullableIntGeneratesAKeyComplexWith2Collections()
+ {
+ using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
+ {
+ var idents = new List<int>();
+ for (int i = 0; i < 15; i++)
+ {
+ var testint = new TestIntGeneration { _id = null };
+ mongo.GetCollection<TestIntGeneration>("Fake").Insert(testint);
+ idents.Add(testint._id.Value);
+ }
+
+ var idents2 = new List<int>();
+ for (int i = 0; i < 15; i++)
+ {
+ var testint = new TestIntGeneration { _id = null };
+ mongo.GetCollection<TestIntGeneration>("Faker").Insert(testint);
+ idents2.Add(testint._id.Value);
+ }
+
+ var list = mongo.GetCollection<TestIntGeneration>("Fake").Find(new { _id = Q.In(idents.ToArray()) });
+ var list2 = mongo.GetCollection<TestIntGeneration>("Faker").Find(new { _id = Q.In(idents2.ToArray()) });
+
+ foreach (var item in list)
+ {
+ Assert.True(idents.Contains(item._id.Value));
+ }
+
+ foreach (var item in list2)
+ {
+ Assert.True(idents2.Contains(item._id.Value));
+ }
+
+ Assert.Equal(idents.Distinct().Count(), list.Select(x => x._id.Value).Distinct().Count());
+ Assert.Equal(idents2.Distinct().Count(), list2.Select(x => x._id.Value).Distinct().Count());
+ }
}
[Fact]

0 comments on commit 721515e

Please sign in to comment.
Something went wrong with that request. Please try again.