markrendle/Simple.Data — Issue #128: Exists and Count (and other aggregate) doesn't work for InMemoryAdapter
Author: marcushammarberg
Created: 2011-11-28 19:13:43+00:00
State: open

I would love to help out fixing this but right now I don't understand how. Please educate me and I'll send a pull request.

Here are the failing tests:

```C#
[Test]
public void ShouldBeAbleToUseCount()
{
// Arrange
Database.UseMockAdapter(new InMemoryAdapter());
var db = Database.Open();
db.Users.Insert(Id: 1, Name: "Bob", Age: 30);
db.Users.Insert(Id: 2, Name: "Alice", Age: 18);
db.Users.Insert(Id: 3, Name: "Maria", Age: 12);
db.Users.Insert(Id: 4, Name: "John", Age: 8);

// Act
var adults = db.Users.Count(db.Users.Age >= 18);

// Assert
Assert.AreEqual(2, adults);
}

[Test]
public void ExistsByNameShouldReturnTrueForExistingData()
{
// Arrange
Database.UseMockAdapter(new InMemoryAdapter());
var db = Database.Open();
db.Users.Insert(Id: 1, Name: "Bob", Age: 30);

// Act
var bobExists = db.Users.ExsistsByName("Bob");

// Assert
Assert.AreEqual(true, bobExists);
}

[Test]
public void ExistsByNameShouldReturnFalseForNonExistingData()
{
// Arrange
Database.UseMockAdapter(new InMemoryAdapter());
var db = Database.Open();
db.Users.Insert(Id: 1, Name: "Alice", Age: 30);

// Act
var bobExists = db.Users.ExsistsByName("Bob");

// Assert
Assert.AreEqual(true, bobExists);
}
```