This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
forked from mongodb-csharp/mongodb-csharp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2802698
commit de04140
Showing
3 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using NUnit.Framework; | ||
using MongoDB.Attributes; | ||
using MongoDB.Configuration; | ||
|
||
namespace MongoDB.Issues | ||
{ | ||
[TestFixture] | ||
public class Issue19 | ||
{ | ||
private class Post | ||
{ | ||
[MongoId] | ||
public Guid Id { get; set; } | ||
|
||
public DateTime LastAccess { get; set; } | ||
public List<string> Tags { get; set; } | ||
} | ||
|
||
[Test] | ||
public void Should_return_an_empty_list() | ||
{ | ||
var SearchTags = new List<string> { "test" }; | ||
using (var mongo = new Mongo()) | ||
{ | ||
mongo.Connect(); | ||
var db = mongo.GetDatabase("posts"); | ||
var posts = db.GetCollection<Post>(); | ||
posts.Remove(x => true); | ||
posts.Insert(new Post() { Tags = new List<string> { "test", "funny" } }); | ||
|
||
var result = SearchTags | ||
.Aggregate(posts.Linq(), (current, tag) => current.Where(x => x.Tags.Contains(tag))) | ||
.OrderByDescending(x => x.LastAccess) | ||
.ToList(); | ||
|
||
Assert.AreEqual(1, result.Count); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters