Skip to content

Commit

Permalink
Added tests for fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
markrendle committed Sep 5, 2011
2 parents 6b677fa + d7a2c7a commit 4e5aa12
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 58 deletions.
1 change: 1 addition & 0 deletions CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@

[assembly: AssemblyVersion("0.9.4.1")]
[assembly: AssemblyFileVersion("0.9.4.1")]

4 changes: 2 additions & 2 deletions Simple.Data.Ado/Simple.Data.Ado.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Simple.Data.Ado</id>
<version>0.9.3.1</version>
<version>0.9.3.2</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>ADO Adapter for the Simple.Data data access library.</description>
Expand All @@ -12,7 +12,7 @@
<tags>sqlserver database data ado .net40</tags>
<language>en-us</language>
<dependencies>
<dependency id="Simple.Data.Core" version="0.9.3.1" />
<dependency id="Simple.Data.Core" version="0.9.3.2" />
</dependencies>
</metadata>
</package>
4 changes: 2 additions & 2 deletions Simple.Data.Mocking/Simple.Data.Mocking.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.Mocking</id>
<version>0.9.3.1</version>
<version>0.9.3.2</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>XML-based Mocking adapter for the Simple.Data data access library.</description>
Expand All @@ -12,7 +12,7 @@
<tags>database data .net40</tags>
<language>en-us</language>
<dependencies>
<dependency id="Simple.Data.Ado" version="0.9.3.1" />
<dependency id="Simple.Data.Ado" version="0.9.3.2" />
</dependencies>
</metadata>
</package>
4 changes: 2 additions & 2 deletions Simple.Data.SqlCe40/Simple.Data.SqlCe40.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.SqlCompact40</id>
<version>0.9.3.1</version>
<version>0.9.3.2</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>SQL Server Compact 4.0 ADO provider for the Simple.Data data access library.</description>
Expand All @@ -12,7 +12,7 @@
<tags>sqlserver compact sqlce database data ado .net40</tags>
<language>en-us</language>
<dependencies>
<dependency id="Simple.Data.Ado" version="0.9.3.1" />
<dependency id="Simple.Data.Ado" version="0.9.3.2" />
</dependencies>
</metadata>
</package>
3 changes: 2 additions & 1 deletion Simple.Data.SqlCe40/SqlCeDbParameterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class SqlCeDbParameterFactory : IDbParameterFactory
public IDbDataParameter CreateParameter(string name, Column column)
{
var sqlCeColumn = (SqlCeColumn) column;
return new SqlCeParameter(name, sqlCeColumn.SqlDbType, column.MaxLength, column.ActualName);

return new SqlCeParameter(name, sqlCeColumn.SqlDbType, 0, column.ActualName);
}

public IDbDataParameter CreateParameter(string name, DbType dbType, int maxLength)
Expand Down
4 changes: 2 additions & 2 deletions Simple.Data.SqlServer/Simple.Data.SqlServer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.SqlServer</id>
<version>0.9.3.1</version>
<version>0.9.3.2</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>SQL Server ADO provider for the Simple.Data data access library.</description>
Expand All @@ -12,7 +12,7 @@
<tags>sqlserver database data ado .net40</tags>
<language>en-us</language>
<dependencies>
<dependency id="Simple.Data.Ado" version="0.9.3.1" />
<dependency id="Simple.Data.Ado" version="0.9.3.2" />
</dependencies>
</metadata>
</package>
8 changes: 8 additions & 0 deletions Simple.Data.SqlTest/FindTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public void TestFindAllByName()
Assert.AreEqual(1, users.Count());
}

[Test]
public void TestFindAllByNameAsIEnumerableOfDynamic()
{
var db = DatabaseHelper.Open();
IEnumerable<dynamic> users = db.Users.FindAllByName("Bob");
Assert.AreEqual(1, users.Count());
}

[Test]
public void TestFindAllByPartialName()
{
Expand Down
2 changes: 1 addition & 1 deletion Simple.Data.SqlTest/QueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void WithTotalCountShouldGiveCount()
Promise<int> count;
var db = DatabaseHelper.Open();
var list = db.PagingTest.QueryById(1.to(50))
.WithTotalCount(out count)
.Take(10)
.WithTotalCount(out count)
.ToList();

Assert.AreEqual(10, list.Count);
Expand Down
94 changes: 47 additions & 47 deletions Simple.Data.SqlTest/SqlQueryPagerTest.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NUnit.Framework;
using Simple.Data.SqlServer;

namespace Simple.Data.SqlTest
{
[TestFixture]
public class SqlQueryPagerTest
{
static readonly Regex Normalize = new Regex(@"\s+", RegexOptions.Multiline);

[Test]
public void ShouldApplyPagingUsingOrderBy()
{
const string sql = "select a,b,c from d where a = 1 order by c";
const string expected =
"with __data as (select a,b,c, row_number() over(order by c) as [_#_] from d where a = 1)"
+ " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take";

var modified = new SqlQueryPager().ApplyPaging(sql, "@skip", "@take");
modified = Normalize.Replace(modified, " ").ToLowerInvariant();

Assert.AreEqual(expected, modified);
}

[Test]
public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
{
const string sql = "select a,b,c from d where a = 1";
const string expected =
"with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
+ " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take";

var modified = new SqlQueryPager().ApplyPaging(sql, "@skip", "@take");
modified = Normalize.Replace(modified, " ").ToLowerInvariant();

Assert.AreEqual(expected, modified);
}

[Test]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NUnit.Framework;
using Simple.Data.SqlServer;

namespace Simple.Data.SqlTest
{
[TestFixture]
public class SqlQueryPagerTest
{
static readonly Regex Normalize = new Regex(@"\s+", RegexOptions.Multiline);

[Test]
public void ShouldApplyPagingUsingOrderBy()
{
const string sql = "select a,b,c from d where a = 1 order by c";
const string expected =
"with __data as (select a,b,c, row_number() over(order by c) as [_#_] from d where a = 1)"
+ " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take";

var modified = new SqlQueryPager().ApplyPaging(sql, "@skip", "@take");
modified = Normalize.Replace(modified, " ").ToLowerInvariant();

Assert.AreEqual(expected, modified);
}

[Test]
public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
{
const string sql = "select a,b,c from d where a = 1";
const string expected =
"with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
+ " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take";

var modified = new SqlQueryPager().ApplyPaging(sql, "@skip", "@take");
modified = Normalize.Replace(modified, " ").ToLowerInvariant();

Assert.AreEqual(expected, modified);
}

[Test]
public void ShouldCopeWithAliasedColumns()
{
const string sql = "select [a],[b] as [foo],[c] from [d] where [a] = 1";
Expand All @@ -53,6 +53,6 @@ public void ShouldCopeWithAliasedColumns()
modified = Normalize.Replace(modified, " ").ToLowerInvariant();

Assert.AreEqual(expected, modified);
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion Simple.Data/Simple.Data.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Simple.Data.Core</id>
<version>0.9.3.1</version>
<version>0.9.3.2</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
Expand Down

0 comments on commit 4e5aa12

Please sign in to comment.