Skip to content

Commit

Permalink
Added MonoTouch unit test project
Browse files Browse the repository at this point in the history
  • Loading branch information
praeclarum committed Sep 20, 2012
1 parent 0761928 commit 88b81e0
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 2 deletions.
11 changes: 10 additions & 1 deletion tests/ByteArrayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ public class ByteArrayClass
public void AssertEquals(ByteArrayClass other)
{
Assert.AreEqual(other.ID, ID);
CollectionAssert.AreEqual(other.bytes, bytes);
if (other.bytes == null || bytes == null) {
Assert.IsNull (other.bytes);
Assert.IsNull (bytes);
}
else {
Assert.AreEqual(other.bytes.Length, bytes.Length);
for (var i = 0; i < bytes.Length; i++) {
Assert.AreEqual(other.bytes[i], bytes[i]);
}
}
}
}

Expand Down
16 changes: 15 additions & 1 deletion tests/CreateTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,25 @@ public void CreateAsPassedInTypes ()

VerifyCreations(db);
}

[Test]
public void CreateTwice ()
{
var db = new TestDb ();

db.CreateTable<Product> ();
db.CreateTable<OrderLine> ();
db.CreateTable<Order> ();
db.CreateTable<OrderLine> ();
db.CreateTable<OrderHistory> ();

VerifyCreations(db);
}

private static void VerifyCreations(TestDb db)
{
var orderLine = db.GetMapping(typeof(OrderLine));
Assert.AreEqual(6, orderLine.Columns.Length, "Order history has 3 columns");
Assert.AreEqual(6, orderLine.Columns.Length);

var l = new OrderLine()
{
Expand Down
32 changes: 32 additions & 0 deletions tests/SQLiteTouchTests.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteTouchTests", "SQLiteTouchTests\SQLiteTouchTests.csproj", "{D61A2E10-513B-4F20-8046-CAA914CEE437}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
Ad-Hoc|iPhone = Ad-Hoc|iPhone
AppStore|iPhone = AppStore|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.AppStore|iPhone.Build.0 = AppStore|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Debug|iPhone.ActiveCfg = Debug|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Debug|iPhone.Build.0 = Debug|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Release|iPhone.ActiveCfg = Release|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Release|iPhone.Build.0 = Release|iPhone
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{D61A2E10-513B-4F20-8046-CAA914CEE437}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = SQLiteTouchTests\SQLiteTouchTests.csproj
EndGlobalSection
EndGlobal
46 changes: 46 additions & 0 deletions tests/SQLiteTouchTests/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.NUnit.UI;

namespace SQLiteTouchTests
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
TouchRunner runner;

//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
runner = new TouchRunner (window);

// register every tests included in the main application/assembly
runner.Add (System.Reflection.Assembly.GetExecutingAssembly ());

window.RootViewController = new UINavigationController (runner.GetViewController ());

// make the window visible
window.MakeKeyAndVisible ();

return true;
}
}
}

26 changes: 26 additions & 0 deletions tests/SQLiteTouchTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>3.2</string>
</dict>
</plist>
20 changes: 20 additions & 0 deletions tests/SQLiteTouchTests/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace SQLiteTouchTests
{
public class Application
{
// This is the main entry point of the application.
static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
}
}
}
173 changes: 173 additions & 0 deletions tests/SQLiteTouchTests/SQLiteTouchTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D61A2E10-513B-4F20-8046-CAA914CEE437}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>SQLiteTouchTests</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>SQLiteTouchTests</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<MtouchDebug>True</MtouchDebug>
<MtouchProfiling>True</MtouchProfiling>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>True</MtouchDebug>
<MtouchProfiling>True</MtouchProfiling>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchArch>ARMv7</MtouchArch>
<MtouchI18n />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
<DebugType>none</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<BuildIpa>True</BuildIpa>
<CodesignKey>iPhone Distribution</CodesignKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
<DebugType>none</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\iPhone\AppStore</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Distribution</CodesignKey>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="MonoTouch.NUnitLite" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="..\AsyncTests.cs">
<Link>AsyncTests.cs</Link>
</Compile>
<Compile Include="..\BooleanTest.cs">
<Link>BooleanTest.cs</Link>
</Compile>
<Compile Include="..\ByteArrayTest.cs">
<Link>ByteArrayTest.cs</Link>
</Compile>
<Compile Include="..\CollateTest.cs">
<Link>CollateTest.cs</Link>
</Compile>
<Compile Include="..\ContainsTest.cs">
<Link>ContainsTest.cs</Link>
</Compile>
<Compile Include="..\CreateTableTest.cs">
<Link>CreateTableTest.cs</Link>
</Compile>
<Compile Include="..\DateTimeTest.cs">
<Link>DateTimeTest.cs</Link>
</Compile>
<Compile Include="..\DeleteTest.cs">
<Link>DeleteTest.cs</Link>
</Compile>
<Compile Include="..\DropTableTest.cs">
<Link>DropTableTest.cs</Link>
</Compile>
<Compile Include="..\ExceptionAssert.cs">
<Link>ExceptionAssert.cs</Link>
</Compile>
<Compile Include="..\GuidTests.cs">
<Link>GuidTests.cs</Link>
</Compile>
<Compile Include="..\InheritanceTest.cs">
<Link>InheritanceTest.cs</Link>
</Compile>
<Compile Include="..\InsertTest.cs">
<Link>InsertTest.cs</Link>
</Compile>
<Compile Include="..\JoinTest.cs">
<Link>JoinTest.cs</Link>
</Compile>
<Compile Include="..\LinqTest.cs">
<Link>LinqTest.cs</Link>
</Compile>
<Compile Include="..\MappingTest.cs">
<Link>MappingTest.cs</Link>
</Compile>
<Compile Include="..\NullableTest.cs">
<Link>NullableTest.cs</Link>
</Compile>
<Compile Include="..\ScalarTest.cs">
<Link>ScalarTest.cs</Link>
</Compile>
<Compile Include="..\SkipTest.cs">
<Link>SkipTest.cs</Link>
</Compile>
<Compile Include="..\StringQueryTest.cs">
<Link>StringQueryTest.cs</Link>
</Compile>
<Compile Include="..\TestDb.cs">
<Link>TestDb.cs</Link>
</Compile>
<Compile Include="..\TransactionTest.cs">
<Link>TransactionTest.cs</Link>
</Compile>
<Compile Include="..\UnicodeTest.cs">
<Link>UnicodeTest.cs</Link>
</Compile>
<Compile Include="..\UniqueTest.cs">
<Link>UniqueTest.cs</Link>
</Compile>
<Compile Include="..\..\src\SQLite.cs">
<Link>SQLite.cs</Link>
</Compile>
<Compile Include="..\..\src\SQLiteAsync.cs">
<Link>SQLiteAsync.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 88b81e0

Please sign in to comment.