Skip to content

Commit

Permalink
Getting the Metro tests in place. Not working due to missing DLL
Browse files Browse the repository at this point in the history
  • Loading branch information
praeclarum committed May 24, 2012
1 parent bbe299d commit f15e9cc
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -7,4 +7,4 @@ _Resharper*
obj
bin
tests/test-results

tests/TestResults/
111 changes: 14 additions & 97 deletions tests/AsyncTests.cs
Expand Up @@ -3,11 +3,14 @@
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;

#if NETFX_CORE
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Windows.UI.Xaml.Shapes;
using SetUp = Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute;
using TestFixture = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
#else
using NUnit.Framework;
#endif
Expand Down Expand Up @@ -35,20 +38,12 @@ public class Customer
/// <summary>
/// Defines tests that exercise async behaviour.
/// </summary>
#if NETFX_CORE
[TestClass]
#else
[TestFixture]
#endif
public class AsyncTests
{
private const string DatabaseName = "async.db";

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void StressAsync ()
{
string path = null;
Expand All @@ -61,7 +56,7 @@ public void StressAsync ()
var n = 500;
var errors = new List<string> ();
for (var i = 0; i < n; i++) {
ThreadPool.QueueUserWorkItem (delegate {
Task.Factory.StartNew (delegate {
try {
var conn = GetConnection ();
var obj = new Customer {
Expand Down Expand Up @@ -134,15 +129,21 @@ SQLiteAsyncConnection GetConnection ()
[SetUp]
public void SetUp()
{
SQLite.SQLiteConnectionPool.Shared.Reset ();
#if NETFX_CORE
_connectionString = DatabaseName;
_path = _connectionString;
_path = Path.Combine (Windows.Storage.ApplicationData.Current.LocalFolder.Path, DatabaseName);
try {
var f = Windows.Storage.StorageFile.GetFileFromPathAsync (_path).AsTask ().Result;
f.DeleteAsync ().AsTask ().Wait ();
}
catch (Exception) {
}
#else
_connectionString = Path.Combine (Path.GetTempPath (), DatabaseName);
_path = _connectionString;
#endif
SQLite.SQLiteConnectionPool.Shared.Reset ();
System.IO.File.Delete (_path);
#endif
}

SQLiteAsyncConnection GetConnection (ref string path)
Expand All @@ -151,11 +152,7 @@ SQLiteAsyncConnection GetConnection (ref string path)
return new SQLiteAsyncConnection (_connectionString);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestDropTableAsync ()
{
string path = null;
Expand Down Expand Up @@ -183,11 +180,7 @@ private Customer CreateCustomer ()
return customer;
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestInsertAsync ()
{
// create...
Expand All @@ -212,11 +205,7 @@ public void TestInsertAsync ()
}
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestUpdateAsync ()
{
// create...
Expand Down Expand Up @@ -245,11 +234,7 @@ public void TestUpdateAsync ()
}
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestDeleteAsync ()
{
// create...
Expand All @@ -274,11 +259,7 @@ public void TestDeleteAsync ()
}
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestGetAsync ()
{
// create...
Expand All @@ -305,11 +286,7 @@ public void TestGetAsync ()
Assert.AreEqual (customer.Id, loaded.Id);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestFindAsyncItemPresent ()
{
// create...
Expand All @@ -333,11 +310,7 @@ public void TestFindAsyncItemPresent ()
Assert.AreEqual (customer.Id, loaded.Id);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestFindAsyncItemMissing ()
{
// connect and insert...
Expand All @@ -352,11 +325,7 @@ public void TestFindAsyncItemMissing ()
Assert.IsNull (task.Result);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestQueryAsync ()
{
// connect...
Expand Down Expand Up @@ -385,11 +354,7 @@ public void TestQueryAsync ()
Assert.AreEqual (customers[2].Email, loaded[0].Email);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestTableAsync ()
{
// connect...
Expand Down Expand Up @@ -425,11 +390,7 @@ public void TestTableAsync ()
Assert.IsNotNull (loaded.Where (v => v.Id == customers[4].Id));
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestExecuteAsync ()
{
// connect...
Expand All @@ -450,11 +411,7 @@ public void TestExecuteAsync ()
}
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestInsertAllAsync ()
{
// create a bunch of customers...
Expand Down Expand Up @@ -485,11 +442,7 @@ public void TestInsertAllAsync ()
}
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestRunInTransactionAsync ()
{
// connect...
Expand Down Expand Up @@ -519,11 +472,7 @@ public void TestRunInTransactionAsync ()
}
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestExecuteScalar ()
{
// connect...
Expand All @@ -537,11 +486,7 @@ public void TestExecuteScalar ()
Assert.AreNotEqual ("Customer", name);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableQueryToListAsync ()
{
var conn = GetConnection ();
Expand All @@ -562,11 +507,7 @@ public void TestAsyncTableQueryToListAsync ()
Assert.AreEqual (customer.Email, loaded.Email);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableQueryWhereOperation ()
{
var conn = GetConnection ();
Expand All @@ -587,11 +528,7 @@ public void TestAsyncTableQueryWhereOperation ()
Assert.AreEqual (customer.Email, loaded.Email);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableQueryCountAsync ()
{
var conn = GetConnection ();
Expand All @@ -611,11 +548,7 @@ public void TestAsyncTableQueryCountAsync ()
Assert.AreEqual (10, task.Result);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableOrderBy ()
{
var conn = GetConnection ();
Expand All @@ -636,11 +569,7 @@ public void TestAsyncTableOrderBy ()
Assert.AreEqual (-1, string.Compare (items[0].Email, items[9].Email));
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableOrderByDescending ()
{
var conn = GetConnection ();
Expand All @@ -661,11 +590,7 @@ public void TestAsyncTableOrderByDescending ()
Assert.AreEqual (1, string.Compare (items[0].Email, items[9].Email));
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableQueryTake ()
{
var conn = GetConnection ();
Expand All @@ -690,11 +615,7 @@ public void TestAsyncTableQueryTake ()
Assert.AreEqual ("0", items[0].FirstName);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableQuerySkip ()
{
var conn = GetConnection ();
Expand All @@ -719,11 +640,7 @@ public void TestAsyncTableQuerySkip ()
Assert.AreEqual ("5", items[0].FirstName);
}

#if NETFX_CORE
[TestMethod]
#else
[Test]
#endif
public void TestAsyncTableElementAtAsync ()
{
var conn = GetConnection ();
Expand Down
46 changes: 46 additions & 0 deletions tests/SQLiteMetroTests.sln
@@ -0,0 +1,46 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 11
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteMetroTests", "SQLiteMetroTests\SQLiteMetroTests.csproj", "{909DE315-2F55-4A20-A9AD-460D4B2A3908}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|ARM.ActiveCfg = Debug|ARM
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|ARM.Build.0 = Debug|ARM
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|ARM.Deploy.0 = Debug|ARM
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|Any CPU.Build.0 = Debug|Any CPU
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|x64.ActiveCfg = Debug|x64
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|x64.Build.0 = Debug|x64
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|x64.Deploy.0 = Debug|x64
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|x86.ActiveCfg = Debug|x86
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|x86.Build.0 = Debug|x86
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Debug|x86.Deploy.0 = Debug|x86
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|ARM.ActiveCfg = Release|ARM
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|ARM.Build.0 = Release|ARM
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|ARM.Deploy.0 = Release|ARM
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|Any CPU.ActiveCfg = Release|Any CPU
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|Any CPU.Build.0 = Release|Any CPU
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|Any CPU.Deploy.0 = Release|Any CPU
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|x64.ActiveCfg = Release|x64
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|x64.Build.0 = Release|x64
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|x64.Deploy.0 = Release|x64
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|x86.ActiveCfg = Release|x86
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|x86.Build.0 = Release|x86
{909DE315-2F55-4A20-A9AD-460D4B2A3908}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added tests/SQLiteMetroTests/Images/UnitTestLogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/SQLiteMetroTests/Images/UnitTestSmallLogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f15e9cc

Please sign in to comment.