Skip to content

Commit 44a3589

Browse files
committed
Fixes for issue ThatRendle#227
1 parent c5483ad commit 44a3589

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
namespace Simple.Data.IntegrationTest
2+
{
3+
using System;
4+
using Mocking.Ado;
5+
using NUnit.Framework;
6+
7+
[TestFixture]
8+
public class GetCountTest : DatabaseIntegrationContext
9+
{
10+
protected override void SetSchema(MockSchemaProvider schemaProvider)
11+
{
12+
schemaProvider.SetTables(new[] {"dbo", "Users", "BASE TABLE"});
13+
14+
schemaProvider.SetColumns(new object[] {"dbo", "Users", "Id", true},
15+
new[] {"dbo", "Users", "Name"},
16+
new[] {"dbo", "Users", "Password"},
17+
new[] {"dbo", "Users", "Age"});
18+
}
19+
20+
[Test]
21+
public void GetCountBasic()
22+
{
23+
EatException<SimpleDataException>(() => _db.Users.GetCount());
24+
GeneratedSqlIs("select count(*) from [dbo].[users]");
25+
}
26+
27+
[Test]
28+
public void GetCountWithColumnThrowsException()
29+
{
30+
Assert.Throws<BadExpressionException>(() => _db.Users.GetCount(_db.Users.Id));
31+
}
32+
33+
[Test]
34+
public void AssigningToColumnThrowsException()
35+
{
36+
Assert.Throws<BadExpressionException>(() => _db.Users.GetCount(_db.Users.Id = 1));
37+
}
38+
39+
[Test]
40+
public void MultipleArgumentsThrowsException()
41+
{
42+
Assert.Throws<ArgumentException>(() => _db.Users.GetCount(_db.Users.Id == 1, _db.Users.Name == "Bob"));
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)