Initial commit of first working version that is used in production environment.

This commit is contained in:
grzegorz.russek
2012-08-10 10:14:49 +00:00
commit 6996111bec
46 changed files with 8489 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynamORM.Tests</RootNamespace>
<AssemblyName>DynamORM.Tests</AssemblyName>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Private>False</Private>
<Package>nunit</Package>
</Reference>
<Reference Include="Mono.Data.Sqlite" />
</ItemGroup>
<ItemGroup>
<Compile Include="Modify\DynamicModificationTests.cs" />
<Compile Include="Modify\DynamicNoSchemaModificationTests.cs" />
<Compile Include="Modify\DynamicTypeSchemaModificationTests.cs" />
<Compile Include="Select\DynamicNoSchemaAccessTests.cs" />
<Compile Include="Select\DynamicTypeSchemaAccessTests.cs" />
<Compile Include="Helpers\AttachToDebugger.cs" />
<Compile Include="Select\DynamicAccessTests.cs" />
<Compile Include="Helpers\Users.cs" />
<Compile Include="Helpers\UsersBareBoneClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Select\RenamedTypedAccessTests.cs" />
<Compile Include="TestsBase.cs" />
<Compile Include="Select\TypedAccessTests.cs" />
<Compile Include="Helpers\PoolingTests.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DynamORM\DynamORM.csproj">
<Project>{63963ED7-9C78-4672-A4D4-339B6E825503}</Project>
<Name>DynamORM</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D5013B4E-8A1B-4DBB-8FB5-E09935F4F764}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynamORM.Tests</RootNamespace>
<AssemblyName>DynamORM.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>lib\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\PoolingTests.cs" />
<Compile Include="Modify\DynamicModificationTests.cs" />
<Compile Include="Modify\DynamicNoSchemaModificationTests.cs" />
<Compile Include="Modify\DynamicTypeSchemaModificationTests.cs" />
<Compile Include="Select\DynamicNoSchemaAccessTests.cs" />
<Compile Include="Select\DynamicTypeSchemaAccessTests.cs" />
<Compile Include="Helpers\AttachToDebugger.cs" />
<Compile Include="Select\DynamicAccessTests.cs" />
<Compile Include="Helpers\Users.cs" />
<Compile Include="Helpers\UsersBareBoneClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Select\RenamedTypedAccessTests.cs" />
<Compile Include="TestsBase.cs" />
<Compile Include="Select\TypedAccessTests.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DynamORM\DynamORM.csproj">
<Project>{63963ED7-9C78-4672-A4D4-339B6E825503}</Project>
<Name>DynamORM</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,57 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Diagnostics;
using NUnit.Framework;
namespace DynamORM.Tests.Helpers
{
/// <summary>Class responsible for users operations testing.</summary>
[TestFixture]
public class AttachToDebugger
{
/// <summary>Attach to debugger.</summary>
[Test]
[Explicit("Test for attaching debugger to NUnit test framework")]
public void Attach()
{
if (!Debugger.IsAttached)
Debugger.Launch();
}
/// <summary>Test anonymous type compatybility.</summary>
[Test]
public void TestAnonType()
{
var a = new { x = 1, y = 2 };
var b = new { x = 3, y = 4 };
Assert.AreEqual(a.GetType(), b.GetType());
}
}
}

View File

@@ -0,0 +1,57 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Diagnostics;
using NUnit.Framework;
namespace DynamORM.Tests.Helpers
{
/// <summary>Class responsible for users operations testing.</summary>
[TestFixture]
public class AttachToDebugger
{
/// <summary>Attach to debugger.</summary>
[Test]
[Explicit("Test for attaching debugger to NUnit test framework")]
public void Attach()
{
if (!Debugger.IsAttached)
Debugger.Launch();
}
/// <summary>Test anonymous type compatybility.</summary>
[Test]
public void TestAnonType ()
{
var a = new { x = 1, y = 2 };
var b = new { x = 3, y = 4 };
Assert.AreEqual (a.GetType (), b.GetType ());
}
}
}

View File

@@ -0,0 +1,101 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using NUnit.Framework;
namespace DynamORM.Tests.Helpers
{
/// <summary>Pooling tests.</summary>
[TestFixture]
public class PoolingTests : TestsBase
{
/// <summary>Setup test parameters.</summary>
[TestFixtureSetUp]
public virtual void SetUp()
{
CreateTestDatabase();
}
/// <summary>Tear down test objects.</summary>
[TestFixtureTearDown]
public virtual void TearDown()
{
DestroyDynamicDatabase();
DestroyTestDatabase();
}
/// <summary>Test single mode command disposing.</summary>
[Test]
public void TestSingleModeCommand()
{
CreateDynamicDatabase();
var cmd = Database.Open().CreateCommand();
cmd.SetCommand("SELECT COUNT(0) FROM sqlite_master;");
Database.Dispose();
Database = null;
Assert.Throws<ObjectDisposedException>(() => cmd.ExecuteScalar());
}
/// <summary>Test single mode transaction disposing.</summary>
[Test]
public void TestSingleModeTransaction()
{
try
{
CreateDynamicDatabase();
using (var conn = Database.Open())
using (var trans = conn.BeginTransaction())
using (var cmd = conn.CreateCommand())
{
Assert.AreEqual(1, cmd.SetCommand("INSERT INTO \"users\" (\"code\") VALUES ('999');").ExecuteNonQuery());
Database.Dispose();
Database = null;
trans.Commit();
}
// Verify (rollback)
CreateDynamicDatabase();
Assert.AreEqual(0, Database.Table("users").Count(columns: "id", code: "999"));
}
finally
{
// Remove for next tests
Database.Dispose();
Database = null;
}
}
}
}

View File

@@ -0,0 +1,73 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using DynamORM.Mapper;
namespace DynamORM.Tests.Helpers
{
/// <summary>Users table representation.</summary>
[Table(Name = "users", Override = true)]
public class Users
{
/// <summary>Gets or sets id column value.</summary>
[Column("id", true)]
public long Id { get; set; }
/// <summary>Gets or sets code column value.</summary>
[Column("code")]
public string Code { get; set; }
/// <summary>Gets or sets login column value.</summary>
[Column("login")]
public string Login { get; set; }
/// <summary>Gets or sets first columnvalue.</summary>
[Column("first")]
public string First { get; set; }
/// <summary>Gets or sets last column value.</summary>
[Column("last")]
public string Last { get; set; }
/// <summary>Gets or sets password column value.</summary>
[Column("password")]
public string Password { get; set; }
/// <summary>Gets or sets email column value.</summary>
[Column("email")]
public string Email { get; set; }
/// <summary>Gets or sets quote column value.</summary>
[Column("quote")]
public string Quote { get; set; }
/// <summary>Gets or sets value of aggregate fields.</summary>
[Ignore]
public object AggregateField { get; set; }
}
}

View File

@@ -0,0 +1,67 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Diagnostics.CodeAnalysis;
using DynamORM.Mapper;
namespace DynamORM.Tests.Helpers
{
/// <summary>Users table representation.</summary>
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Bare bone table mapping.")]
public class users
{
/// <summary>Gets or sets id column value.</summary>
[Column("id", true)]
public long id { get; set; }
/// <summary>Gets or sets code column value.</summary>
public string code { get; set; }
/// <summary>Gets or sets login column value.</summary>
public string login { get; set; }
/// <summary>Gets or sets first columnvalue.</summary>
public string first { get; set; }
/// <summary>Gets or sets last column value.</summary>
public string last { get; set; }
/// <summary>Gets or sets password column value.</summary>
public string password { get; set; }
/// <summary>Gets or sets email column value.</summary>
public string email { get; set; }
/// <summary>Gets or sets quote column value.</summary>
public string quote { get; set; }
/// <summary>Gets or sets value of aggregate fields.</summary>
[Ignore]
public object aggregatefield { get; set; }
}
}

View File

@@ -0,0 +1,390 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using DynamORM.Tests.Helpers;
using NUnit.Framework;
namespace DynamORM.Tests.Modify
{
/// <summary>Test standard dynamic access ORM.</summary>
[TestFixture]
public class DynamicModificationTests : TestsBase
{
/// <summary>Setup test parameters.</summary>
[TestFixtureSetUp]
public virtual void SetUp()
{
CreateTestDatabase();
CreateDynamicDatabase();
}
/// <summary>Tear down test objects.</summary>
[TestFixtureTearDown]
public virtual void TearDown()
{
DestroyDynamicDatabase();
DestroyTestDatabase();
}
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public virtual dynamic GetTestTable()
{
return Database.Table("users");
}
#region Insert
/// <summary>Test row insertion by dynamic arguments.</summary>
[Test]
public void TestInsertByArguments()
{
Assert.AreEqual(1, GetTestTable().Insert(code: 201, first: "Juri", last: "Gagarin", email: "juri.gagarin@megacorp.com", quote: "bla, bla, bla"));
// Verify
var o = GetTestTable().Single(code: 201);
Assert.Less(200, o.id);
Assert.AreEqual("201", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row insertion by dynamic object.</summary>
[Test]
public void TestInsertByDynamicObjects()
{
Assert.AreEqual(1, GetTestTable().Insert(values: new { code = 202, first = "Juri", last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
// Verify
var o = GetTestTable().Single(code: 202);
Assert.Less(200, o.id);
Assert.AreEqual("202", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row insertion by mapped object.</summary>
[Test]
public void TestInsertByMappedObject()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Insert(values: new Users
{
Id = u.Max(columns: "id") + 1,
Code = "203",
First = "Juri",
Last = "Gagarin",
Email = "juri.gagarin@megacorp.com",
Quote = "bla, bla, bla"
}));
// Verify
var o = u.Single(code: 203);
Assert.Less(200, o.id);
Assert.AreEqual("203", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row insertion by basic object.</summary>
[Test]
public void TestInsertByBasicObject()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Insert(values: new users
{
id = u.Max(columns: "id") + 1,
code = "204",
first = "Juri",
last = "Gagarin",
email = "juri.gagarin@megacorp.com",
quote = "bla, bla, bla"
}));
// Verify
var o = u.Single(code: 204);
Assert.Less(200, o.id);
Assert.AreEqual("204", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
#endregion Insert
#region Update
/// <summary>Test row updating by dynamic arguments.</summary>
[Test]
public void TestUpdateByArguments()
{
Assert.AreEqual(1, GetTestTable().Update(id: 1, code: 201, first: "Juri", last: "Gagarin", email: "juri.gagarin@megacorp.com", quote: "bla, bla, bla"));
// Verify
var o = GetTestTable().Single(code: 201);
Assert.AreEqual(1, o.id);
Assert.AreEqual("201", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row updating by dynamic objects.</summary>
[Test]
public void TestUpdateByDynamicObject()
{
Assert.AreEqual(1, GetTestTable().Update(update: new { id = 2, code = 202, first = "Juri", last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
// Verify
var o = GetTestTable().Single(code: 202);
Assert.AreEqual(2, o.id);
Assert.AreEqual("202", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row updating by mapped object.</summary>
[Test]
public void TestUpdateByMappedObject()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Update(update: new Users
{
Id = 3,
Code = "203",
First = "Juri",
Last = "Gagarin",
Email = "juri.gagarin@megacorp.com",
Quote = "bla, bla, bla"
}));
// Verify
var o = u.Single(code: 203);
Assert.AreEqual(3, o.id);
Assert.AreEqual("203", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row updating by basic object.</summary>
[Test]
public void TestUpdateByBasicObject()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Update(update: new users
{
id = 4,
code = "204",
first = "Juri",
last = "Gagarin",
email = "juri.gagarin@megacorp.com",
quote = "bla, bla, bla"
}));
// Verify
var o = u.Single(code: 204);
Assert.AreEqual(4, o.id);
Assert.AreEqual("204", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row updating by dynamic objects.</summary>
[Test]
public void TestUpdateByDynamicObjects()
{
Assert.AreEqual(1, GetTestTable().Update(values: new { code = 205, first = "Juri", last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }, where: new { id = 5 }));
// Verify
var o = GetTestTable().Single(code: 205);
Assert.AreEqual(5, o.id);
Assert.AreEqual("205", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row updating by mapped objects.</summary>
[Test]
public void TestUpdateByMappedObjects()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Update(values: new Users
{
Id = 6,
Code = "206",
First = "Juri",
Last = "Gagarin",
Email = "juri.gagarin@megacorp.com",
Quote = "bla, bla, bla"
}, id: 6));
// Verify
var o = u.Single(code: 206);
Assert.AreEqual(6, o.id);
Assert.AreEqual("206", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
/// <summary>Test row updating by basic objects.</summary>
[Test]
public void TestUpdateByBasicObjects()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Update(values: new users
{
id = 7,
code = "207",
first = "Juri",
last = "Gagarin",
email = "juri.gagarin@megacorp.com",
quote = "bla, bla, bla"
}, id: 7));
// Verify
var o = u.Single(code: 207);
Assert.AreEqual(7, o.id);
Assert.AreEqual("207", o.code);
Assert.AreEqual("Juri", o.first);
Assert.AreEqual("Gagarin", o.last);
Assert.AreEqual("juri.gagarin@megacorp.com", o.email);
Assert.AreEqual("bla, bla, bla", o.quote);
Assert.AreEqual(null, o.password);
}
#endregion Update
#region Delete
/// <summary>Test row deleting by dynamic arguments.</summary>
[Test]
public void TestDeleteByArguments()
{
Assert.AreEqual(1, GetTestTable().Delete(code: 10));
// Verify
Assert.AreEqual(0, GetTestTable().Count(code: 10));
}
/// <summary>Test row deleting by dynamic objects (all except ID should be ignored).</summary>
[Test]
public void TestDeleteyDynamicObject()
{
Assert.AreEqual(1, GetTestTable().Delete(delete: new { id = 11, code = 11, first = "Juri", last = "Gagarin", email = "juri.gagarin@megacorp.com", quote = "bla, bla, bla" }));
// Verify
Assert.AreEqual(0, GetTestTable().Count(id: 11));
}
/// <summary>Test row deleting by mapped object.</summary>
[Test]
public void TestDeleteByMappedObject()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Delete(delete: new Users
{
Id = 12,
Code = "12",
First = "Juri",
Last = "Gagarin",
Email = "juri.gagarin@megacorp.com",
Quote = "bla, bla, bla"
}));
// Verify
Assert.AreEqual(0, GetTestTable().Count(id: 12));
}
/// <summary>Test row deleting by basic object.</summary>
[Test]
public void TestDeleteByBasicObject()
{
var u = GetTestTable();
Assert.AreEqual(1, u.Delete(delete: new users
{
id = 13,
code = "13",
first = "Juri",
last = "Gagarin",
email = "juri.gagarin@megacorp.com",
quote = "bla, bla, bla"
}));
// Verify
Assert.AreEqual(0, GetTestTable().Count(id: 13));
}
/// <summary>Test row deleting by dynamic objects (all except ID should be ignored).</summary>
[Test]
public void TestDeleteyDynamicObjectWhere()
{
Assert.AreEqual(1, GetTestTable().Delete(where: new { id = 14, code = 14 }));
// Verify
Assert.AreEqual(0, GetTestTable().Count(id: 14));
}
#endregion Delete
}
}

View File

@@ -0,0 +1,55 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using NUnit.Framework;
namespace DynamORM.Tests.Modify
{
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
[TestFixture]
public class DynamicNoSchemaModificationTests : DynamicModificationTests
{
/// <summary>Setup test parameters.</summary>
[TestFixtureSetUp]
public override void SetUp()
{
CreateTestDatabase();
CreateDynamicDatabase(
DynamicDatabaseOptions.SingleConnection |
DynamicDatabaseOptions.SingleTransaction |
DynamicDatabaseOptions.SupportLimitOffset);
}
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public override dynamic GetTestTable()
{
return Database.Table("users", new string[] { "id" });
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using DynamORM.Tests.Helpers;
using NUnit.Framework;
namespace DynamORM.Tests.Modify
{
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
[TestFixture]
public class DynamicTypeSchemaModificationTests : DynamicModificationTests
{
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public override dynamic GetTestTable()
{
return Database.Table<users>();
}
}
}

View File

@@ -0,0 +1,65 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* See: http://opensource.org/licenses/bsd-license.php
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DynamORM.Tests")]
[assembly: AssemblyDescription("Dynamic Object-Relational Mapping tests library.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("RUSSEK Software")]
[assembly: AssemblyProduct("DynamORM")]
[assembly: AssemblyCopyright("Copyright © RUSSEK Software 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1d8b751b-b3ec-481d-9f7f-14d6e6eb0fde")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

View File

@@ -0,0 +1,75 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.269
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DynamORM.Tests.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DynamORM.Tests.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to CREATE TABLE users (id INTEGER NOT NULL PRIMARY KEY, code, login text, first text, last text, password text, email text, quote text);
///INSERT INTO users (code,first,last,email,quote) VALUES (&apos;1&apos;,&apos;Clarke&apos;,&apos;Jarvis&apos;,&apos;eu.accumsan@nonarcuVivamus.org&apos;,&apos;non leo. Vivamus&apos;);
///INSERT INTO users (code,first,last,email,quote) VALUES (&apos;2&apos;,&apos;Marny&apos;,&apos;Fry&apos;,&apos;Cras.convallis.convallis@nisiCumsociis.ca&apos;,&apos;aliquam eu, accumsan sed, facilisis vitae, orci. Phasellus&apos;);
///INSERT INTO users (code,first,last,email,quote) VALUES (&apos;3&apos;,&apos; [rest of string was truncated]&quot;;.
/// </summary>
internal static string UsersTable {
get {
return ResourceManager.GetString("UsersTable", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,324 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="UsersTable" xml:space="preserve">
<value>CREATE TABLE users (id INTEGER NOT NULL PRIMARY KEY, code, login text, first text, last text, password text, email text, quote text);
INSERT INTO users (code,first,last,email,quote) VALUES ('1','Clarke','Jarvis','eu.accumsan@nonarcuVivamus.org','non leo. Vivamus');
INSERT INTO users (code,first,last,email,quote) VALUES ('2','Marny','Fry','Cras.convallis.convallis@nisiCumsociis.ca','aliquam eu, accumsan sed, facilisis vitae, orci. Phasellus');
INSERT INTO users (code,first,last,email,quote) VALUES ('3','Dai','Marks','dictum.augue@venenatis.ca','nulla ante, iaculis nec, eleifend non, dapibus rutrum, justo. Praesent');
INSERT INTO users (code,first,last,email,quote) VALUES ('4','Forrest','Hendricks','justo.sit.amet@odioa.edu','auctor. Mauris vel turpis. Aliquam adipiscing lobortis');
INSERT INTO users (code,first,last,email,quote) VALUES ('5','Blossom','Dunlap','libero.mauris@Phasellusfermentumconvallis.ca','luctus sit amet, faucibus ut, nulla. Cras eu tellus eu');
INSERT INTO users (code,first,last,email,quote) VALUES ('6','George','Rios','vitae@sodales.ca','elit. Aliquam auctor, velit eget laoreet');
INSERT INTO users (code,first,last,email,quote) VALUES ('7','Ivory','Henderson','elit.Aliquam.auctor@Nullamvelitdui.ca','Fusce diam nunc, ullamcorper');
INSERT INTO users (code,first,last,email,quote) VALUES ('8','Inez','Goodwin','consectetuer.mauris@nibhPhasellus.edu','eu, placerat eget, venenatis a, magna.');
INSERT INTO users (code,first,last,email,quote) VALUES ('9','Sigourney','Gonzales','lectus.pede.ultrices@sagittislobortismauris.org','egestas hendrerit');
INSERT INTO users (code,first,last,email,quote) VALUES ('10','Fulton','Terrell','penatibus@euaugue.com','Nulla interdum. Curabitur dictum.');
INSERT INTO users (code,first,last,email,quote) VALUES ('11','Logan','Freeman','malesuada.malesuada@nullaIntegervulputate.edu','dui, semper et, lacinia');
INSERT INTO users (code,first,last,email,quote) VALUES ('12','Anne','Irwin','lorem.ut.aliquam@ligula.org','erat, in consectetuer ipsum nunc id enim.');
INSERT INTO users (code,first,last,email,quote) VALUES ('13','Alexandra','Church','sit@sempererat.org','lorem, luctus ut, pellentesque eget, dictum placerat, augue. Sed');
INSERT INTO users (code,first,last,email,quote) VALUES ('14','Adena','Branch','sit.amet@accumsanlaoreetipsum.org','natoque penatibus et');
INSERT INTO users (code,first,last,email,quote) VALUES ('15','Lionel','Hoover','ac@Donectempor.ca','at pede. Cras vulputate');
INSERT INTO users (code,first,last,email,quote) VALUES ('16','Aimee','Strickland','ornare.lectus@tinciduntduiaugue.ca','vitae odio sagittis semper. Nam');
INSERT INTO users (code,first,last,email,quote) VALUES ('17','Selma','Williamson','metus.In.nec@quamquisdiam.org','id nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('18','Lara','Trujillo','lacus@convallisest.edu','Integer sem elit, pharetra ut,');
INSERT INTO users (code,first,last,email,quote) VALUES ('19','Ori','Ellis','egestas@at.ca','odio. Nam interdum');
INSERT INTO users (code,first,last,email,quote) VALUES ('20','Macey','Carey','sed.consequat@ametorciUt.org','magna');
INSERT INTO users (code,first,last,email,quote) VALUES ('21','Quynn','Randall','Cras.dictum@malesuada.org','egestas. Fusce aliquet magna a neque.');
INSERT INTO users (code,first,last,email,quote) VALUES ('22','Alec','Robles','Fusce.feugiat@mollisdui.com','a');
INSERT INTO users (code,first,last,email,quote) VALUES ('23','Jakeem','Bell','ante@laoreetlectusquis.edu','eget massa. Suspendisse eleifend. Cras');
INSERT INTO users (code,first,last,email,quote) VALUES ('24','Katelyn','Cannon','sit.amet@PhasellusornareFusce.org','nisi dictum augue malesuada malesuada.');
INSERT INTO users (code,first,last,email,quote) VALUES ('25','Christian','Alford','per@vulputate.ca','turpis.');
INSERT INTO users (code,first,last,email,quote) VALUES ('26','Leila','Forbes','nec.ante@idblanditat.ca','ac ipsum. Phasellus');
INSERT INTO users (code,first,last,email,quote) VALUES ('27','Hadley','Gillespie','Lorem.ipsum@Nullamvitaediam.com','vestibulum lorem, sit amet ultricies sem magna nec quam.');
INSERT INTO users (code,first,last,email,quote) VALUES ('28','Julian','Keith','facilisis@loremvitaeodio.edu','nulla at sem molestie sodales. Mauris blandit enim consequat purus.');
INSERT INTO users (code,first,last,email,quote) VALUES ('29','Allen','Ramos','neque@lobortis.ca','amet diam eu dolor egestas rhoncus. Proin nisl sem, consequat');
INSERT INTO users (code,first,last,email,quote) VALUES ('30','Hermione','Walsh','dictum.magna@tincidunt.edu','scelerisque');
INSERT INTO users (code,first,last,email,quote) VALUES ('31','Xena','Graves','eu.dui@tinciduntaliquamarcu.ca','nunc interdum feugiat. Sed nec metus facilisis lorem tristique aliquet.');
INSERT INTO users (code,first,last,email,quote) VALUES ('32','Tanisha','Blackburn','aliquam.eu.accumsan@dui.edu','fringilla mi lacinia mattis. Integer eu');
INSERT INTO users (code,first,last,email,quote) VALUES ('33','Norman','Hobbs','eu.euismod.ac@tinciduntDonecvitae.com','pulvinar arcu et pede. Nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('34','Guy','Molina','non@rutrumurna.org','Vivamus euismod urna.');
INSERT INTO users (code,first,last,email,quote) VALUES ('35','Rama','Albert','nunc@laciniavitaesodales.com','eu augue porttitor interdum. Sed auctor odio a purus. Duis');
INSERT INTO users (code,first,last,email,quote) VALUES ('36','Owen','Combs','Nullam.enim.Sed@magnaPhasellusdolor.com','mollis vitae, posuere at, velit. Cras lorem lorem, luctus');
INSERT INTO users (code,first,last,email,quote) VALUES ('37','Ashely','Graham','eget.odio@enimsitamet.com','commodo at, libero. Morbi accumsan laoreet ipsum. Curabitur consequat,');
INSERT INTO users (code,first,last,email,quote) VALUES ('38','Paul','Levy','nec@leo.com','augue scelerisque mollis. Phasellus libero mauris, aliquam eu, accumsan');
INSERT INTO users (code,first,last,email,quote) VALUES ('39','Octavia','Calderon','eu@maurissitamet.edu','est, mollis non, cursus non,');
INSERT INTO users (code,first,last,email,quote) VALUES ('40','Lenore','Pugh','eu.metus.In@Cumsociisnatoque.com','scelerisque mollis. Phasellus libero mauris, aliquam eu, accumsan sed, facilisis');
INSERT INTO users (code,first,last,email,quote) VALUES ('41','Regan','Clemons','eu.neque.pellentesque@Integerinmagna.ca','Curae;');
INSERT INTO users (code,first,last,email,quote) VALUES ('42','Zachary','Haynes','eu.erat@ipsum.edu','quis lectus. Nullam');
INSERT INTO users (code,first,last,email,quote) VALUES ('43','Dane','Hyde','rhoncus@auctor.com','magna et ipsum cursus vestibulum. Mauris magna. Duis dignissim');
INSERT INTO users (code,first,last,email,quote) VALUES ('44','Mara','Hansen','Nunc.commodo@ultricies.org','magna. Ut tincidunt orci quis lectus. Nullam suscipit, est');
INSERT INTO users (code,first,last,email,quote) VALUES ('45','Zelda','Parrish','turpis.In@rutrummagnaCras.com','Suspendisse aliquet, sem ut cursus luctus, ipsum leo');
INSERT INTO users (code,first,last,email,quote) VALUES ('46','Amaya','Richmond','lacinia.at@in.org','ac, fermentum vel, mauris.');
INSERT INTO users (code,first,last,email,quote) VALUES ('47','Hedda','Murray','ac.fermentum.vel@ipsum.com','tincidunt, neque vitae semper egestas, urna justo faucibus lectus, a');
INSERT INTO users (code,first,last,email,quote) VALUES ('48','Brendan','Macdonald','dignissim@leoMorbi.com','vestibulum lorem, sit');
INSERT INTO users (code,first,last,email,quote) VALUES ('49','Gray','Mccall','risus.Donec@atsem.ca','libero est, congue');
INSERT INTO users (code,first,last,email,quote) VALUES ('50','Shoshana','Tran','nunc.In@aliquet.org','magna sed dui.');
INSERT INTO users (code,first,last,email,quote) VALUES ('51','Sylvester','Parks','Mauris.molestie@ipsumdolorsit.org','nec, eleifend non, dapibus rutrum, justo.');
INSERT INTO users (code,first,last,email,quote) VALUES ('52','Kennan','Stokes','nonummy.ut.molestie@varius.org','Ut nec urna et arcu imperdiet ullamcorper. Duis');
INSERT INTO users (code,first,last,email,quote) VALUES ('53','Quin','Park','porttitor@vulputateeu.com','scelerisque, lorem ipsum sodales');
INSERT INTO users (code,first,last,email,quote) VALUES ('54','Madison','Bailey','nec.orci.Donec@vestibulumnequesed.org','augue. Sed');
INSERT INTO users (code,first,last,email,quote) VALUES ('55','Kenyon','Reilly','ultrices.iaculis.odio@sit.ca','enim. Curabitur massa. Vestibulum accumsan neque');
INSERT INTO users (code,first,last,email,quote) VALUES ('56','Drew','Brooks','molestie.orci@aliquetdiamSed.org','at risus. Nunc ac sem ut dolor dapibus gravida.');
INSERT INTO users (code,first,last,email,quote) VALUES ('57','Omar','Dunn','vel@Donecsollicitudinadipiscing.ca','ultrices posuere cubilia Curae; Phasellus ornare. Fusce mollis. Duis sit');
INSERT INTO users (code,first,last,email,quote) VALUES ('58','Glenna','Lambert','Proin.non@Phasellus.com','neque. In');
INSERT INTO users (code,first,last,email,quote) VALUES ('59','Aspen','Bailey','in.dolor.Fusce@ipsum.org','a, arcu. Sed et libero. Proin');
INSERT INTO users (code,first,last,email,quote) VALUES ('60','Adele','Carlson','velit.justo.nec@vehicularisusNulla.edu','risus.');
INSERT INTO users (code,first,last,email,quote) VALUES ('61','Kerry','Zimmerman','luctus.aliquet.odio@urnajusto.edu','purus. Duis elementum, dui quis accumsan convallis, ante lectus convallis');
INSERT INTO users (code,first,last,email,quote) VALUES ('62','Hedda','Guthrie','vulputate.risus@Phaselluselit.ca','ac mattis velit justo nec');
INSERT INTO users (code,first,last,email,quote) VALUES ('63','Wyoming','Blackburn','nec.ante@lorem.org','ultricies');
INSERT INTO users (code,first,last,email,quote) VALUES ('64','Palmer','Dennis','venenatis.lacus@Donecnonjusto.org','a, arcu. Sed et libero. Proin');
INSERT INTO users (code,first,last,email,quote) VALUES ('65','Wesley','Reeves','massa.Suspendisse.eleifend@nec.edu','consequat');
INSERT INTO users (code,first,last,email,quote) VALUES ('66','Mallory','Todd','Duis@Crasloremlorem.edu','nascetur ridiculus mus. Proin vel arcu eu odio');
INSERT INTO users (code,first,last,email,quote) VALUES ('67','Perry','Kirk','tincidunt.adipiscing@mauris.ca','ullamcorper viverra. Maecenas iaculis aliquet diam. Sed diam lorem,');
INSERT INTO users (code,first,last,email,quote) VALUES ('68','Justina','Horne','enim.nec.tempus@magnanec.com','ipsum ac mi eleifend egestas. Sed pharetra, felis eget');
INSERT INTO users (code,first,last,email,quote) VALUES ('69','Noel','Santana','Duis.elementum.dui@Nullamvitae.org','Phasellus');
INSERT INTO users (code,first,last,email,quote) VALUES ('70','Sylvester','Bridges','Sed.neque@ornarelectusante.org','Maecenas libero');
INSERT INTO users (code,first,last,email,quote) VALUES ('71','Cailin','Baldwin','eu@nibhenim.com','consectetuer');
INSERT INTO users (code,first,last,email,quote) VALUES ('72','Beatrice','Henson','risus.Nunc.ac@Etiam.ca','nec, imperdiet nec, leo. Morbi neque');
INSERT INTO users (code,first,last,email,quote) VALUES ('73','Kellie','Curry','quis.turpis.vitae@Quisque.org','ipsum. Suspendisse non leo.');
INSERT INTO users (code,first,last,email,quote) VALUES ('74','Justine','Stewart','Curabitur@dui.org','natoque penatibus et magnis dis parturient');
INSERT INTO users (code,first,last,email,quote) VALUES ('75','Dean','Waters','quis.turpis@morbi.ca','Nulla interdum. Curabitur dictum. Phasellus in felis. Nulla tempor augue');
INSERT INTO users (code,first,last,email,quote) VALUES ('76','Helen','Porter','molestie.dapibus.ligula@ipsum.com','enim non nisi. Aenean eget');
INSERT INTO users (code,first,last,email,quote) VALUES ('77','Janna','Acosta','lectus.a@tempusrisus.com','lectus justo');
INSERT INTO users (code,first,last,email,quote) VALUES ('78','Libby','Vaughn','nisl.sem.consequat@convallis.ca','purus mauris a nunc.');
INSERT INTO users (code,first,last,email,quote) VALUES ('79','Winifred','Cooke','aliquet.sem.ut@etrutrum.ca','metus facilisis lorem tristique aliquet. Phasellus fermentum convallis ligula. Donec');
INSERT INTO users (code,first,last,email,quote) VALUES ('80','Taylor','Glass','sit@maurissitamet.com','orci, consectetuer euismod');
INSERT INTO users (code,first,last,email,quote) VALUES ('81','Melyssa','Palmer','pharetra.sed.hendrerit@fermentum.ca','neque tellus, imperdiet non, vestibulum nec,');
INSERT INTO users (code,first,last,email,quote) VALUES ('82','Kuame','Holman','Vivamus@Donecnibh.edu','cursus non, egestas a, dui. Cras');
INSERT INTO users (code,first,last,email,quote) VALUES ('83','Martin','Hughes','magna@nonbibendum.org','et ultrices posuere cubilia');
INSERT INTO users (code,first,last,email,quote) VALUES ('84','Roanna','Potter','amet.dapibus@aenim.com','est tempor bibendum. Donec');
INSERT INTO users (code,first,last,email,quote) VALUES ('85','Cleo','Carson','Curabitur.dictum.Phasellus@liberoIntegerin.com','mauris');
INSERT INTO users (code,first,last,email,quote) VALUES ('86','Adele','Daugherty','vulputate.ullamcorper@elitfermentumrisus.edu','consequat purus. Maecenas');
INSERT INTO users (code,first,last,email,quote) VALUES ('87','Macon','Todd','et.malesuada@Crasloremlorem.com','montes, nascetur ridiculus');
INSERT INTO users (code,first,last,email,quote) VALUES ('88','Ira','Merritt','risus@eunullaat.ca','metus.');
INSERT INTO users (code,first,last,email,quote) VALUES ('89','Dustin','Landry','nec.orci.Donec@vulputateeu.com','Nunc pulvinar arcu et pede. Nunc sed');
INSERT INTO users (code,first,last,email,quote) VALUES ('90','Debra','Shepherd','dolor.elit@ornareFusce.ca','Suspendisse non leo. Vivamus');
INSERT INTO users (code,first,last,email,quote) VALUES ('91','Channing','Mcknight','tellus@laoreet.ca','non ante bibendum ullamcorper. Duis cursus, diam at pretium aliquet,');
INSERT INTO users (code,first,last,email,quote) VALUES ('92','Abraham','Rodgers','tincidunt.nibh@ipsum.ca','Cum sociis');
INSERT INTO users (code,first,last,email,quote) VALUES ('93','Abel','Mcintyre','et@turpisvitaepurus.com','at pretium aliquet,');
INSERT INTO users (code,first,last,email,quote) VALUES ('94','Lysandra','Cotton','malesuada.malesuada.Integer@gravidamolestie.org','commodo hendrerit. Donec');
INSERT INTO users (code,first,last,email,quote) VALUES ('95','Kane','Bennett','ante.Vivamus@Donec.ca','consectetuer rhoncus. Nullam velit dui, semper et, lacinia vitae, sodales');
INSERT INTO users (code,first,last,email,quote) VALUES ('96','Timothy','Rivas','hendrerit.consectetuer@nonarcuVivamus.ca','Suspendisse non leo. Vivamus nibh dolor, nonummy ac, feugiat');
INSERT INTO users (code,first,last,email,quote) VALUES ('97','Arden','Cote','magnis@sedestNunc.org','purus mauris a nunc.');
INSERT INTO users (code,first,last,email,quote) VALUES ('98','Brynn','Britt','ac@nibhQuisque.edu','Duis gravida. Praesent eu nulla at sem molestie');
INSERT INTO users (code,first,last,email,quote) VALUES ('99','Jerome','Kirkland','ac@nibhPhasellus.com','neque');
INSERT INTO users (code,first,last,email,quote) VALUES ('100','Hoyt','Tran','ullamcorper.viverra@parturientmontesnascetur.org','ac tellus. Suspendisse sed dolor. Fusce mi');
INSERT INTO users (code,first,last,email,quote) VALUES ('101','Abraham','Downs','velit.eu.sem@neceuismod.ca','suscipit,');
INSERT INTO users (code,first,last,email,quote) VALUES ('102','Vivien','Fletcher','Nunc.ut@quamPellentesquehabitant.edu','lobortis. Class aptent taciti sociosqu ad');
INSERT INTO users (code,first,last,email,quote) VALUES ('103','Azalia','Turner','scelerisque@at.edu','odio sagittis semper. Nam tempor diam dictum');
INSERT INTO users (code,first,last,email,quote) VALUES ('104','Tate','Ellis','velit.Sed.malesuada@Cras.com','sed');
INSERT INTO users (code,first,last,email,quote) VALUES ('105','Dennis','Walls','Nullam.scelerisque@amifringilla.edu','arcu. Vestibulum ut eros non enim commodo hendrerit. Donec porttitor');
INSERT INTO users (code,first,last,email,quote) VALUES ('106','Amela','Collins','Quisque@magna.org','Proin');
INSERT INTO users (code,first,last,email,quote) VALUES ('107','Olivia','Dejesus','scelerisque@vitae.org','Duis cursus, diam at pretium aliquet,');
INSERT INTO users (code,first,last,email,quote) VALUES ('108','Mechelle','Russo','Fusce.aliquet.magna@Praesent.org','penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin');
INSERT INTO users (code,first,last,email,quote) VALUES ('109','Hall','Burke','Vivamus.nibh@pellentesque.edu','et libero. Proin mi. Aliquam');
INSERT INTO users (code,first,last,email,quote) VALUES ('110','Chanda','Ayers','magna.Nam.ligula@NullafacilisiSed.org','dui, semper et, lacinia vitae, sodales at,');
INSERT INTO users (code,first,last,email,quote) VALUES ('111','Abdul','Dominguez','pretium.aliquet.metus@vellectusCum.com','vitae erat vel pede blandit congue. In scelerisque scelerisque dui.');
INSERT INTO users (code,first,last,email,quote) VALUES ('112','Wynter','Lynn','tellus.Aenean@ligulatortordictum.ca','adipiscing fringilla, porttitor vulputate, posuere vulputate, lacus. Cras interdum.');
INSERT INTO users (code,first,last,email,quote) VALUES ('113','Molly','Willis','montes.nascetur@sed.org','sem. Nulla interdum. Curabitur dictum. Phasellus in felis.');
INSERT INTO users (code,first,last,email,quote) VALUES ('114','Shafira','Harper','Phasellus.in.felis@ategestas.edu','Vivamus');
INSERT INTO users (code,first,last,email,quote) VALUES ('115','Otto','Gentry','in.molestie.tortor@Fusce.edu','est. Mauris eu turpis. Nulla aliquet. Proin velit.');
INSERT INTO users (code,first,last,email,quote) VALUES ('116','Todd','Riddle','et@nislsem.com','Nulla');
INSERT INTO users (code,first,last,email,quote) VALUES ('117','Mufutau','Pollard','sit@ridiculusmus.org','accumsan neque et nunc. Quisque ornare tortor at');
INSERT INTO users (code,first,last,email,quote) VALUES ('118','Noah','Sears','tristique.neque.venenatis@luctuslobortis.org','dictum');
INSERT INTO users (code,first,last,email,quote) VALUES ('119','Amanda','Clarke','in.consequat@non.org','nisi dictum augue malesuada malesuada. Integer id magna et ipsum');
INSERT INTO users (code,first,last,email,quote) VALUES ('120','Vladimir','Colon','velit.dui@scelerisquenequeNullam.com','pharetra sed, hendrerit a, arcu. Sed et libero.');
INSERT INTO users (code,first,last,email,quote) VALUES ('121','Aaron','Hernandez','Quisque.ornare.tortor@magna.ca','sit amet ante. Vivamus non lorem vitae odio');
INSERT INTO users (code,first,last,email,quote) VALUES ('122','Bert','Gonzales','fermentum@Nullamvelit.ca','quis massa. Mauris vestibulum, neque sed dictum eleifend, nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('123','Bevis','Leblanc','viverra.Donec@dictumaugue.com','neque sed dictum eleifend, nunc risus varius orci, in');
INSERT INTO users (code,first,last,email,quote) VALUES ('124','Noble','Fisher','Cum@eu.com','Nunc quis arcu');
INSERT INTO users (code,first,last,email,quote) VALUES ('125','Xaviera','Barton','non.arcu@sagittis.com','ultrices posuere cubilia Curae; Phasellus ornare. Fusce mollis. Duis');
INSERT INTO users (code,first,last,email,quote) VALUES ('126','Logan','Roy','Nulla@hendreritconsectetuercursus.com','sed, facilisis vitae, orci. Phasellus dapibus');
INSERT INTO users (code,first,last,email,quote) VALUES ('127','Wilma','Sweet','Nullam.nisl.Maecenas@gravidasagittis.org','ut, nulla. Cras');
INSERT INTO users (code,first,last,email,quote) VALUES ('128','Candace','Olsen','sit.amet@lobortisnisi.com','habitant morbi tristique senectus et netus et malesuada');
INSERT INTO users (code,first,last,email,quote) VALUES ('129','Claire','Alvarado','risus.varius@interdumSed.com','a felis ullamcorper viverra. Maecenas iaculis aliquet');
INSERT INTO users (code,first,last,email,quote) VALUES ('130','Aurelia','Bean','diam.dictum.sapien@eu.edu','libero. Integer in magna. Phasellus');
INSERT INTO users (code,first,last,email,quote) VALUES ('131','Carly','Wilcox','massa.non.ante@Aliquam.com','vehicula risus. Nulla eget metus eu erat semper rutrum. Fusce');
INSERT INTO users (code,first,last,email,quote) VALUES ('132','Xanthus','Graves','vulputate.velit.eu@vitaerisus.com','Cras sed leo. Cras vehicula aliquet libero. Integer in magna.');
INSERT INTO users (code,first,last,email,quote) VALUES ('133','Uta','Justice','adipiscing@consequatdolor.edu','Nam tempor diam dictum sapien. Aenean massa.');
INSERT INTO users (code,first,last,email,quote) VALUES ('134','Alika','Parker','faucibus.ut@Fuscemilorem.edu','vel, venenatis vel, faucibus id,');
INSERT INTO users (code,first,last,email,quote) VALUES ('135','Kasimir','Pugh','sed.turpis@FuscefeugiatLorem.com','justo. Praesent luctus. Curabitur egestas nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('136','Brock','Acevedo','dapibus.rutrum@convallisconvallisdolor.org','eu enim. Etiam');
INSERT INTO users (code,first,last,email,quote) VALUES ('137','Orla','Hogan','in@Aliquamauctor.com','ac turpis egestas. Aliquam fringilla cursus purus. Nullam scelerisque neque');
INSERT INTO users (code,first,last,email,quote) VALUES ('138','Tatyana','Bean','molestie.arcu@sempercursus.edu','pellentesque, tellus');
INSERT INTO users (code,first,last,email,quote) VALUES ('139','Cadman','Humphrey','auctor@Aeneangravida.edu','eget, dictum');
INSERT INTO users (code,first,last,email,quote) VALUES ('140','Delilah','Quinn','Pellentesque.habitant@liberoMorbi.edu','lobortis quam a felis');
INSERT INTO users (code,first,last,email,quote) VALUES ('141','Briar','Prince','euismod@Aeneangravida.com','at, libero.');
INSERT INTO users (code,first,last,email,quote) VALUES ('142','Hedda','Garrett','eleifend@sitamet.org','ac turpis');
INSERT INTO users (code,first,last,email,quote) VALUES ('143','Sage','Hardy','semper@acfeugiat.org','Nunc laoreet lectus quis massa.');
INSERT INTO users (code,first,last,email,quote) VALUES ('144','Iris','Meyers','Duis.a.mi@Donecnibhenim.edu','vitae aliquam eros turpis non enim. Mauris quis');
INSERT INTO users (code,first,last,email,quote) VALUES ('145','Hayes','Bates','molestie@magnaSuspendisse.com','fringilla. Donec feugiat metus sit amet ante.');
INSERT INTO users (code,first,last,email,quote) VALUES ('146','Rana','Cain','malesuada@loremsitamet.edu','mi');
INSERT INTO users (code,first,last,email,quote) VALUES ('147','acqueline','Mays','est.Nunc.laoreet@est.edu','odio. Phasellus at augue id ante dictum cursus. Nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('148','Nichole','Suarez','cursus.purus.Nullam@ac.edu','Sed malesuada augue ut lacus. Nulla');
INSERT INTO users (code,first,last,email,quote) VALUES ('149','Sasha','Sparks','fermentum@nonenim.edu','Sed dictum. Proin eget odio.');
INSERT INTO users (code,first,last,email,quote) VALUES ('150','Timon','Lowery','suscipit@Donecat.edu','pede blandit congue. In scelerisque scelerisque dui. Suspendisse ac metus');
INSERT INTO users (code,first,last,email,quote) VALUES ('151','Ivor','Charles','augue.eu@odiovelest.org','quis urna. Nunc quis arcu vel quam dignissim');
INSERT INTO users (code,first,last,email,quote) VALUES ('152','Joelle','Trevino','eget@diamdictumsapien.ca','tortor, dictum eu, placerat eget, venenatis a,');
INSERT INTO users (code,first,last,email,quote) VALUES ('153','Aristotle','Wall','at@Pellentesqueutipsum.com','quis,');
INSERT INTO users (code,first,last,email,quote) VALUES ('154','Amena','Boyd','elit.Etiam@vehiculaet.com','molestie dapibus');
INSERT INTO users (code,first,last,email,quote) VALUES ('155','Rashad','Osborn','ac@aliquam.ca','sed');
INSERT INTO users (code,first,last,email,quote) VALUES ('156','Theodore','Williamson','dignissim.magna@volutpat.ca','Fusce fermentum fermentum');
INSERT INTO users (code,first,last,email,quote) VALUES ('157','Rajah','Logan','enim@Aliquamerat.com','nunc. Quisque ornare tortor');
INSERT INTO users (code,first,last,email,quote) VALUES ('158','Zane','Perez','aliquet@aliquetPhasellus.com','pede.');
INSERT INTO users (code,first,last,email,quote) VALUES ('159','Jena','Rios','urna@velitegetlaoreet.org','eu erat semper rutrum.');
INSERT INTO users (code,first,last,email,quote) VALUES ('160','Amber','Gallagher','conubia@elit.org','Maecenas ornare egestas');
INSERT INTO users (code,first,last,email,quote) VALUES ('161','Veda','Pittman','habitant.morbi.tristique@aliquamenimnec.ca','risus');
INSERT INTO users (code,first,last,email,quote) VALUES ('162','Nathan','Lowe','dui.Cum.sociis@Sed.org','sed, est. Nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('163','Matthew','Townsend','commodo.auctor.velit@egestasadui.ca','ligula. Aenean euismod');
INSERT INTO users (code,first,last,email,quote) VALUES ('164','Oscar','Richards','vulputate.ullamcorper@eueleifendnec.ca','laoreet ipsum. Curabitur consequat, lectus sit');
INSERT INTO users (code,first,last,email,quote) VALUES ('165','Gareth','Jackson','nec.diam.Duis@nisl.com','iaculis nec, eleifend non, dapibus rutrum, justo. Praesent luctus.');
INSERT INTO users (code,first,last,email,quote) VALUES ('166','Alice','Hyde','Sed.auctor.odio@tortor.edu','id, libero. Donec consectetuer mauris id sapien. Cras dolor');
INSERT INTO users (code,first,last,email,quote) VALUES ('167','Giacomo','Ramos','et.ipsum.cursus@massanon.edu','auctor non, feugiat nec, diam. Duis');
INSERT INTO users (code,first,last,email,quote) VALUES ('168','Ciara','Jacobson','Donec.egestas.Aliquam@Aeneangravidanunc.edu','molestie tellus.');
INSERT INTO users (code,first,last,email,quote) VALUES ('169','Logan','Hendricks','luctus@vulputatedui.ca','in, cursus et, eros. Proin ultrices. Duis volutpat nunc');
INSERT INTO users (code,first,last,email,quote) VALUES ('170','MacKenzie','Campos','luctus.ut.pellentesque@pellentesquea.edu','erat,');
INSERT INTO users (code,first,last,email,quote) VALUES ('171','Nina','Best','purus.sapien@aliquet.ca','dolor sit amet, consectetuer');
INSERT INTO users (code,first,last,email,quote) VALUES ('172','Chester','Howe','Cum.sociis.natoque@Duis.ca','dui, nec tempus');
INSERT INTO users (code,first,last,email,quote) VALUES ('173','Nora','Callahan','in.hendrerit@ametconsectetueradipiscing.com','tempus');
INSERT INTO users (code,first,last,email,quote) VALUES ('174','Molly','Bray','consectetuer@velitSedmalesuada.edu','lorem fringilla ornare placerat, orci lacus vestibulum lorem, sit');
INSERT INTO users (code,first,last,email,quote) VALUES ('175','Ariel','Osborn','et@Aeneanegestashendrerit.ca','enim. Sed nulla ante, iaculis nec,');
INSERT INTO users (code,first,last,email,quote) VALUES ('176','Arsenio','Leblanc','Pellentesque.ut.ipsum@nibh.com','elit pede, malesuada vel, venenatis vel, faucibus id, libero.');
INSERT INTO users (code,first,last,email,quote) VALUES ('177','Deborah','Bowman','enim.Etiam@primisinfaucibus.ca','eu nibh vulputate mauris');
INSERT INTO users (code,first,last,email,quote) VALUES ('178','Delilah','Horton','tincidunt.nunc@arcuet.ca','nec ante. Maecenas mi');
INSERT INTO users (code,first,last,email,quote) VALUES ('179','Isaiah','Buckley','Fusce.feugiat@massa.org','ut');
INSERT INTO users (code,first,last,email,quote) VALUES ('180','Logan','Jacobs','Phasellus@utsemNulla.ca','ullamcorper eu, euismod');
INSERT INTO users (code,first,last,email,quote) VALUES ('181','Lesley','Brown','fringilla@erateget.com','nostra, per inceptos');
INSERT INTO users (code,first,last,email,quote) VALUES ('182','Kay','Dodson','a.purus@velpedeblandit.ca','tortor at risus. Nunc ac sem ut');
INSERT INTO users (code,first,last,email,quote) VALUES ('183','Yeo','Hayes','vitae.posuere.at@scelerisque.com','a, dui. Cras');
INSERT INTO users (code,first,last,email,quote) VALUES ('184','Keegan','Brock','molestie.tellus@convallisestvitae.ca','mi eleifend egestas. Sed pharetra, felis eget varius ultrices,');
INSERT INTO users (code,first,last,email,quote) VALUES ('185','Kim','Foley','at@acrisusMorbi.com','scelerisque sed, sapien.');
INSERT INTO users (code,first,last,email,quote) VALUES ('186','Celeste','Delacruz','ipsum.non.arcu@vulputate.edu','Donec fringilla. Donec feugiat metus');
INSERT INTO users (code,first,last,email,quote) VALUES ('187','Hilda','Rowe','gravida.sit@nisi.ca','eu nulla at sem molestie sodales. Mauris blandit enim');
INSERT INTO users (code,first,last,email,quote) VALUES ('188','Fuller','Mclaughlin','purus.gravida.sagittis@arcu.com','erat. Sed nunc est, mollis non, cursus non, egestas a,');
INSERT INTO users (code,first,last,email,quote) VALUES ('189','Madeline','Henderson','lorem.fringilla@cursusdiam.com','Sed pharetra, felis eget varius ultrices, mauris');
INSERT INTO users (code,first,last,email,quote) VALUES ('190','Josephine','Osborn','metus@tincidunt.ca','a sollicitudin orci sem eget massa. Suspendisse');
INSERT INTO users (code,first,last,email,quote) VALUES ('191','Ivana','Jimenez','justo@egestasSedpharetra.org','Duis risus odio, auctor vitae, aliquet nec, imperdiet nec, leo.');
INSERT INTO users (code,first,last,email,quote) VALUES ('192','Stephanie','Dickerson','aliquet.nec.imperdiet@Aliquamrutrumlorem.com','nec ante. Maecenas mi felis, adipiscing');
INSERT INTO users (code,first,last,email,quote) VALUES ('193','Yardley','Trevino','lacinia.mattis@porttitoreros.edu','lacus.');
INSERT INTO users (code,first,last,email,quote) VALUES ('194','Carol','Acosta','Donec@aliquetmolestie.ca','arcu');
INSERT INTO users (code,first,last,email,quote) VALUES ('195','Lysandra','Mosley','imperdiet@Suspendissesed.org','viverra. Maecenas iaculis aliquet diam.');
INSERT INTO users (code,first,last,email,quote) VALUES ('196','Tamara','Solis','eleifend.egestas.Sed@duiinsodales.com','sit amet lorem semper auctor. Mauris vel');
INSERT INTO users (code,first,last,email,quote) VALUES ('197','Palmer','Perez','nibh@nonduinec.edu','lacus vestibulum lorem, sit amet');
INSERT INTO users (code,first,last,email,quote) VALUES ('198','Maia','Donaldson','gravida.Aliquam.tincidunt@volutpatNulladignissim.edu','sit amet luctus vulputate, nisi');
INSERT INTO users (code,first,last,email,quote) VALUES ('199','Murphy','Wright','et.pede@aptenttacitisociosqu.ca','non arcu. Vivamus sit amet risus. Donec egestas.');
INSERT INTO users (code,first,last,email,quote) VALUES ('200','Omar','Campos','nunc.ac.mattis@luctussitamet.edu','parturient');
UPDATE users SET login = lower(first || '.' || last);</value>
</data>
</root>

View File

@@ -0,0 +1,322 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace DynamORM.Tests.Select
{
/// <summary>Test standard dynamic access ORM.</summary>
[TestFixture]
public class DynamicAccessTests : TestsBase
{
/// <summary>Setup test parameters.</summary>
[TestFixtureSetUp]
public virtual void SetUp()
{
CreateTestDatabase();
CreateDynamicDatabase();
}
/// <summary>Tear down test objects.</summary>
[TestFixtureTearDown]
public virtual void TearDown()
{
DestroyDynamicDatabase();
DestroyTestDatabase();
}
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public virtual dynamic GetTestTable()
{
return Database.Table("users");
}
#region Select
/// <summary>Test unknown op.</summary>
[Test]
public void TestUnknownOperation()
{
Assert.Throws<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch(with: "cheese"));
}
/// <summary>Test dynamic <c>Count</c> method.</summary>
[Test]
public void TestCount()
{
Assert.AreEqual(200, GetTestTable().Count(columns: "id"));
}
/// <summary>Test count with in steatement.</summary>
[Test]
public void TestSelectInEnumerableCount()
{
Assert.AreEqual(4, GetTestTable().Count(last: new DynamicColumn
{
Operator = DynamicColumn.CompareOperator.In,
Value = new object[] { "Hendricks", "Goodwin", "Freeman" }.Take(3)
}));
}
/// <summary>Test count with in steatement.</summary>
[Test]
public void TestSelectInArrayCount()
{
Assert.AreEqual(4, GetTestTable().Count(last: new DynamicColumn
{
Operator = DynamicColumn.CompareOperator.In,
Value = new object[] { "Hendricks", "Goodwin", "Freeman" }
}));
}
/// <summary>Test dynamic <c>First</c> method.</summary>
[Test]
public void TestFirst()
{
Assert.AreEqual(1, GetTestTable().First(columns: "id").id);
}
/// <summary>Test dynamic <c>Last</c> method.</summary>
[Test]
public void TestLast()
{
Assert.AreEqual(200, GetTestTable().Last(columns: "id").id);
}
/// <summary>Test dynamic <c>Count</c> method.</summary>
[Test]
public void TestCountSpecificRecord()
{
Assert.AreEqual(1, GetTestTable().Count(first: "Ori"));
}
/// <summary>Test dynamic <c>Min</c> method.</summary>
[Test]
public void TestMin()
{
Assert.AreEqual(1, GetTestTable().Min(columns: "id"));
}
/// <summary>Test dynamic <c>Min</c> method.</summary>
[Test]
public void TestMax()
{
Assert.AreEqual(200, GetTestTable().Max(columns: "id"));
}
/// <summary>Test dynamic <c>Min</c> method.</summary>
[Test]
public void TesttAvg()
{
Assert.AreEqual(100.5, GetTestTable().Avg(columns: "id"));
}
/// <summary>Test dynamic <c>Sum</c> method.</summary>
[Test]
public void TestSum()
{
Assert.AreEqual(20100, GetTestTable().Sum(columns: "id"));
}
/// <summary>Test dynamic <c>Scalar</c> method for invalid operation exception.</summary>
[Test]
public void TestScalarException()
{
Assert.Throws<InvalidOperationException>(() => GetTestTable().Scalar(id: 19));
}
/// <summary>Test dynamic <c>Scalar</c> method.</summary>
[Test]
public void TestScalar()
{
Assert.AreEqual("Ori", GetTestTable().Scalar(columns: "first", id: 19));
}
/// <summary>Test dynamic <c>Scalar</c> method with SQLite specific aggregate.</summary>
[Test]
public void TestScalarGroupConcat()
{
// This test should produce something like this:
// select group_concat("first") AS first from "users" where "id" < 20;
Assert.AreEqual("Clarke,Marny,Dai,Forrest,Blossom,George,Ivory,Inez,Sigourney,Fulton,Logan,Anne,Alexandra,Adena,Lionel,Aimee,Selma,Lara,Ori",
GetTestTable().Scalar(columns: "first:first:group_concat", id: new DynamicColumn { Operator = DynamicColumn.CompareOperator.Lt, Value = 20 }));
}
/// <summary>Test dynamic <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
[Test]
public void TestScalarGroupConcatNoAggregateField()
{
// This test should produce something like this:
// select group_concat(first) AS first from "users" where "id" < 20;
Assert.AreEqual("Clarke,Marny,Dai,Forrest,Blossom,George,Ivory,Inez,Sigourney,Fulton,Logan,Anne,Alexandra,Adena,Lionel,Aimee,Selma,Lara,Ori",
GetTestTable().Scalar(columns: "group_concat(first):first", id: new DynamicColumn { Operator = DynamicColumn.CompareOperator.Lt, Value = 20 }));
}
/// <summary>Test something fancy... like: <code>select "first", count("first") occurs from "users" group by "first" order by 2 desc;</code>.</summary>
[Test]
public void TestFancyAggregateQuery()
{
var v = (GetTestTable().Query(columns: "first,first:occurs:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
Assert.IsNotNull(v);
Assert.AreEqual(187, v.Count());
Assert.AreEqual(4, v.First().occurs);
Assert.AreEqual("Logan", v.First().first);
Assert.AreEqual(2, v.Take(10).Last().occurs);
Assert.AreEqual(1, v.Take(11).Last().occurs);
Assert.AreEqual(1, v.Last().occurs);
}
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
[Test]
public void TestAggregateInAggregate()
{
Assert.AreEqual(12.77, GetTestTable().Scalar(columns: @"length(""login""):len:avg"));
}
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
[Test]
public void TestAggregateInAggregateMark2()
{
Assert.AreEqual(27.7, GetTestTable().Avg(columns: @"length(""email""):len"));
}
/// <summary>Test emails longer than 27 chars. <code>select count(*) from "users" where length("email") > 27;</code>.</summary>
public void TestFunctionInWhere()
{
Assert.AreEqual(97,
GetTestTable().Count(condition1:
new DynamicColumn()
{
ColumnName = "email",
Aggregate = "length",
Operator = DynamicColumn.CompareOperator.Gt,
Value = 27
}));
}
/// <summary>Test dynamic <c>Single</c> multi.</summary>
[Test]
public void TestSingleObject()
{
var exp = new { id = 19, first = "Ori", last = "Ellis" };
var o = GetTestTable().Single(columns: "id,first,last", id: 19);
Assert.AreEqual(exp.id, o.id);
Assert.AreEqual(exp.first, o.first);
Assert.AreEqual(exp.last, o.last);
}
#endregion Select
#region Where
/// <summary>Test dynamic where expression equal.</summary>
[Test]
public void TestWhereEq()
{
Assert.AreEqual("hoyt.tran", GetTestTable().Single(where: new DynamicColumn("id").Eq(100)).login);
}
/// <summary>Test dynamic where expression not equal.</summary>
[Test]
public void TestWhereNot()
{
Assert.AreEqual(199, GetTestTable().Count(where: new DynamicColumn("id").Not(100)));
}
/// <summary>Test dynamic where expression like.</summary>
[Test]
public void TestWhereLike()
{
Assert.AreEqual(100, GetTestTable().Single(where: new DynamicColumn("login").Like("Hoyt.%")).id);
}
/// <summary>Test dynamic where expression not like.</summary>
[Test]
public void TestWhereNotLike()
{
Assert.AreEqual(199, GetTestTable().Count(where: new DynamicColumn("login").NotLike("Hoyt.%")));
}
/// <summary>Test dynamic where expression greater.</summary>
[Test]
public void TestWhereGt()
{
Assert.AreEqual(100, GetTestTable().Count(where: new DynamicColumn("id").Greater(100)));
}
/// <summary>Test dynamic where expression greater or equal.</summary>
[Test]
public void TestWhereGte()
{
Assert.AreEqual(101, GetTestTable().Count(where: new DynamicColumn("id").GreaterOrEqual(100)));
}
/// <summary>Test dynamic where expression less.</summary>
[Test]
public void TestWhereLt()
{
Assert.AreEqual(99, GetTestTable().Count(where: new DynamicColumn("id").Less(100)));
}
/// <summary>Test dynamic where expression less or equal.</summary>
[Test]
public void TestWhereLte()
{
Assert.AreEqual(100, GetTestTable().Count(where: new DynamicColumn("id").LessOrEqual(100)));
}
/// <summary>Test dynamic where expression between.</summary>
[Test]
public void TestWhereBetween()
{
Assert.AreEqual(26, GetTestTable().Count(where: new DynamicColumn("id").Between(75, 100)));
}
/// <summary>Test dynamic where expression in params.</summary>
[Test]
public void TestWhereIn1()
{
Assert.AreEqual(3, GetTestTable().Count(where: new DynamicColumn("id").In(75, 99, 100)));
}
/// <summary>Test dynamic where expression in array.</summary>
[Test]
public void TestWhereIn2()
{
Assert.AreEqual(3, GetTestTable().Count(where: new DynamicColumn("id").In(new[] { 75, 99, 100 })));
}
#endregion Where
}
}

View File

@@ -0,0 +1,55 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using NUnit.Framework;
namespace DynamORM.Tests.Select
{
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
[TestFixture]
public class DynamicNoSchemaAccessTests : DynamicAccessTests
{
/// <summary>Setup test parameters.</summary>
[TestFixtureSetUp]
public override void SetUp()
{
CreateTestDatabase();
CreateDynamicDatabase(
DynamicDatabaseOptions.SingleConnection |
DynamicDatabaseOptions.SingleTransaction |
DynamicDatabaseOptions.SupportLimitOffset);
}
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public override dynamic GetTestTable()
{
return Database.Table("users", new string[] { "id" });
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using DynamORM.Tests.Helpers;
using NUnit.Framework;
namespace DynamORM.Tests.Select
{
/// <summary>Test standard dynamic access ORM. With out schema information from database.</summary>
[TestFixture]
public class DynamicTypeSchemaAccessTests : DynamicNoSchemaAccessTests
{
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public override dynamic GetTestTable()
{
return Database.Table<users>();
}
}
}

View File

@@ -0,0 +1,149 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using System.Linq;
using DynamORM.Tests.Helpers;
using NUnit.Framework;
namespace DynamORM.Tests.Select
{
/// <summary>Test typed ORM.</summary>
public class RenamedTypedAccessTests : TypedAccessTests<Users>
{
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
[Test]
public override void TestTypedFancyAggregateQuery()
{
var v = (GetTestTable().Query(type: typeof(Users), columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
Assert.IsNotNull(v);
Assert.AreEqual(187, v.Count());
Assert.AreEqual(4, v.First().AggregateField);
Assert.AreEqual("Logan", v.First().First);
Assert.AreEqual(2, v.Take(10).Last().AggregateField);
Assert.AreEqual(1, v.Take(11).Last().AggregateField);
Assert.AreEqual(1, v.Last().AggregateField);
}
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
[Test]
public override void TestGenericFancyAggregateQuery()
{
var v = (GetTestTable().Query<Users>(columns: "first,first:AggregateField:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
Assert.IsNotNull(v);
Assert.AreEqual(187, v.Count());
Assert.AreEqual(4, v.First().AggregateField);
Assert.AreEqual("Logan", v.First().First);
Assert.AreEqual(2, v.Take(10).Last().AggregateField);
Assert.AreEqual(1, v.Take(11).Last().AggregateField);
Assert.AreEqual(1, v.Last().AggregateField);
}
/// <summary>Test typed <c>First</c> method.</summary>
[Test]
public override void TestTypedFirst()
{
Assert.AreEqual(1, GetTestTable().First(type: typeof(Users), columns: "id").Id);
}
/// <summary>Test typed <c>Last</c> method.</summary>
[Test]
public override void TestTypedLast()
{
Assert.AreEqual(200, GetTestTable().Last(type: typeof(Users), columns: "id").Id);
}
/// <summary>Test typed <c>Single</c> multi.</summary>
[Test]
public override void TestTypedSingleObject()
{
var exp = new { id = 19, first = "Ori", last = "Ellis" };
var o = GetTestTable().Single(type: typeof(Users), columns: "id,first,last", id: 19);
Assert.AreEqual(exp.id, o.Id);
Assert.AreEqual(exp.first, o.First);
Assert.AreEqual(exp.last, o.Last);
}
/// <summary>Test typed where expression equal.</summary>
[Test]
public override void TestTypedWhereEq()
{
Assert.AreEqual("hoyt.tran", GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("id").Eq(100)).Login);
}
/// <summary>Test typed where expression like.</summary>
[Test]
public override void TestTypedWhereLike()
{
Assert.AreEqual(100, GetTestTable().Single(type: typeof(Users), where: new DynamicColumn("login").Like("Hoyt.%")).Id);
}
/// <summary>Test generic <c>First</c> method.</summary>
[Test]
public override void TestGenericFirst()
{
Assert.AreEqual(1, GetTestTable().First<Users>(columns: "id").Id);
}
/// <summary>Test generic <c>Last</c> method.</summary>
[Test]
public override void TestGenericLast()
{
Assert.AreEqual(200, GetTestTable().Last<Users>(columns: "id").Id);
}
/// <summary>Test generic <c>Single</c> multi.</summary>
[Test]
public override void TestGenericSingleObject()
{
var exp = new { id = 19, first = "Ori", last = "Ellis" };
var o = GetTestTable().Single<Users>(columns: "id,first,last", id: 19);
Assert.AreEqual(exp.id, o.Id);
Assert.AreEqual(exp.first, o.First);
Assert.AreEqual(exp.last, o.Last);
}
/// <summary>Test generic where expression equal.</summary>
[Test]
public override void TestGenericWhereEq()
{
Assert.AreEqual("hoyt.tran", GetTestTable().Single<Users>(where: new DynamicColumn("id").Eq(100)).Login);
}
/// <summary>Test generic where expression like.</summary>
[Test]
public override void TestGenericWhereLike()
{
Assert.AreEqual(100, GetTestTable().Single<Users>(where: new DynamicColumn("login").Like("Hoyt.%")).Id);
}
}
}

View File

@@ -0,0 +1,604 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using DynamORM.Tests.Helpers;
using NUnit.Framework;
namespace DynamORM.Tests.Select
{
/// <summary>Test typed ORM.</summary>
/// <typeparam name="T">Type to test.</typeparam>
[TestFixture(typeof(users))]
public class TypedAccessTests<T> : TestsBase
{
/// <summary>Setup test parameters.</summary>
[TestFixtureSetUp]
public virtual void SetUp()
{
CreateTestDatabase();
CreateDynamicDatabase();
// Cache table (profiler freaks out)
GetTestTable();
}
/// <summary>Tear down test objects.</summary>
[TestFixtureTearDown]
public virtual void TearDown()
{
DestroyDynamicDatabase();
DestroyTestDatabase();
}
/// <summary>Create table using specified method.</summary>
/// <returns>Dynamic table.</returns>
public virtual dynamic GetTestTable()
{
return Database.Table();
}
#region Select typed
/// <summary>Test load all rows into mapped list alternate way.</summary>
[Test]
public virtual void TestTypedGetAll()
{
var list = (GetTestTable().Query(type: typeof(T)) as IEnumerable<object>).Cast<T>().ToList();
Assert.AreEqual(200, list.Count);
}
/// <summary>Test unknown op.</summary>
[Test]
public virtual void TestTypedUnknownOperation()
{
Assert.Throws<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch(type: typeof(T), with: "cheese"));
}
/// <summary>Test typed <c>Count</c> method.</summary>
[Test]
public virtual void TestTypedCount()
{
Assert.AreEqual(200, GetTestTable().Count(type: typeof(T), columns: "id"));
}
/// <summary>Test count with in steatement.</summary>
[Test]
public virtual void TestTypedSelectInEnumerableCount()
{
Assert.AreEqual(4, GetTestTable().Count(type: typeof(T), last: new DynamicColumn
{
Operator = DynamicColumn.CompareOperator.In,
Value = new object[] { "Hendricks", "Goodwin", "Freeman" }.Take(3)
}));
}
/// <summary>Test count with in steatement.</summary>
[Test]
public virtual void TestTypedSelectInArrayCount()
{
Assert.AreEqual(4, GetTestTable().Count(type: typeof(T), last: new DynamicColumn
{
Operator = DynamicColumn.CompareOperator.In,
Value = new object[] { "Hendricks", "Goodwin", "Freeman" }
}));
}
/// <summary>Test typed <c>First</c> method.</summary>
[Test]
public virtual void TestTypedFirst()
{
Assert.AreEqual(1, GetTestTable().First(type: typeof(T), columns: "id").id);
}
/// <summary>Test typed <c>Last</c> method.</summary>
[Test]
public virtual void TestTypedLast()
{
Assert.AreEqual(200, GetTestTable().Last(type: typeof(T), columns: "id").id);
}
/// <summary>Test typed <c>Count</c> method.</summary>
[Test]
public virtual void TestTypedCountSpecificRecord()
{
Assert.AreEqual(1, GetTestTable().Count(type: typeof(T), first: "Ori"));
}
/// <summary>Test typed <c>Min</c> method.</summary>
[Test]
public virtual void TestTypedMin()
{
Assert.AreEqual(1, GetTestTable().Min(type: typeof(T), columns: "id"));
}
/// <summary>Test typed <c>Min</c> method.</summary>
[Test]
public virtual void TestTypedMax()
{
Assert.AreEqual(200, GetTestTable().Max(type: typeof(T), columns: "id"));
}
/// <summary>Test typed <c>Min</c> method.</summary>
[Test]
public virtual void TestTypedtAvg()
{
Assert.AreEqual(100.5, GetTestTable().Avg(type: typeof(T), columns: "id"));
}
/// <summary>Test typed <c>Sum</c> method.</summary>
[Test]
public virtual void TestTypedSum()
{
Assert.AreEqual(20100, GetTestTable().Sum(type: typeof(T), columns: "id"));
}
/// <summary>Test typed <c>Scalar</c> method for invalid operation exception.</summary>
[Test]
public virtual void TestTypedScalarException()
{
Assert.Throws<InvalidOperationException>(() => GetTestTable().Scalar(type: typeof(T), id: 19));
}
/// <summary>Test typed <c>Scalar</c> method.</summary>
[Test]
public virtual void TestTypedScalar()
{
Assert.AreEqual("Ori", GetTestTable().Scalar(type: typeof(T), columns: "first", id: 19));
}
/// <summary>Test typed <c>Scalar</c> method with SQLite specific aggregate.</summary>
[Test]
public virtual void TestTypedScalarGroupConcat()
{
// This test should produce something like this:
// select group_concat("first") AS first from "users" where "id" < 20;
Assert.AreEqual("Clarke,Marny,Dai,Forrest,Blossom,George,Ivory,Inez,Sigourney,Fulton,Logan,Anne,Alexandra,Adena,Lionel,Aimee,Selma,Lara,Ori",
GetTestTable().Scalar(type: typeof(T), columns: "first:first:group_concat", id: new DynamicColumn { Operator = DynamicColumn.CompareOperator.Lt, Value = 20 }));
}
/// <summary>Test typed <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
[Test]
public virtual void TestTypedScalarGroupConcatNoAggregateField()
{
// This test should produce something like this:
// select group_concat(first) AS first from "users" where "id" < 20;
Assert.AreEqual("Clarke,Marny,Dai,Forrest,Blossom,George,Ivory,Inez,Sigourney,Fulton,Logan,Anne,Alexandra,Adena,Lionel,Aimee,Selma,Lara,Ori",
GetTestTable().Scalar(type: typeof(T), columns: "group_concat(first):first", id: new DynamicColumn { Operator = DynamicColumn.CompareOperator.Lt, Value = 20 }));
}
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
[Test]
public virtual void TestTypedFancyAggregateQuery()
{
var v = (GetTestTable().Query(type: typeof(T), columns: "first,first:aggregatefield:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
Assert.IsNotNull(v);
Assert.AreEqual(187, v.Count());
Assert.AreEqual(4, v.First().aggregatefield);
Assert.AreEqual("Logan", v.First().first);
Assert.AreEqual(2, v.Take(10).Last().aggregatefield);
Assert.AreEqual(1, v.Take(11).Last().aggregatefield);
Assert.AreEqual(1, v.Last().aggregatefield);
}
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
[Test]
public virtual void TestTypedAggregateInAggregate()
{
Assert.AreEqual(12.77, GetTestTable().Scalar(type: typeof(T), columns: @"length(""login""):len:avg"));
}
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
[Test]
public virtual void TestTypedAggregateInAggregateMark2()
{
Assert.AreEqual(27.7, GetTestTable().Avg(type: typeof(T), columns: @"length(""email""):len"));
}
/// <summary>Test emails longer than 27 chars. <code>select count(*) from "users" where length("email") > 27;</code>.</summary>
public virtual void TestTypedFunctionInWhere()
{
Assert.AreEqual(97,
GetTestTable().Count(type: typeof(T), condition1:
new DynamicColumn()
{
ColumnName = "email",
Aggregate = "length",
Operator = DynamicColumn.CompareOperator.Gt,
Value = 27
}));
}
/// <summary>Test typed <c>Single</c> multi.</summary>
[Test]
public virtual void TestTypedSingleObject()
{
var exp = new { id = 19, first = "Ori", last = "Ellis" };
var o = GetTestTable().Single(type: typeof(T), columns: "id,first,last", id: 19);
Assert.AreEqual(exp.id, o.id);
Assert.AreEqual(exp.first, o.first);
Assert.AreEqual(exp.last, o.last);
}
#endregion Select typed
#region Where typed
/// <summary>Test typed where expression equal.</summary>
[Test]
public virtual void TestTypedWhereEq()
{
Assert.AreEqual("hoyt.tran", GetTestTable().Single(type: typeof(T), where: new DynamicColumn("id").Eq(100)).login);
}
/// <summary>Test typed where expression not equal.</summary>
[Test]
public virtual void TestTypedWhereNot()
{
Assert.AreEqual(199, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Not(100)));
}
/// <summary>Test typed where expression like.</summary>
[Test]
public virtual void TestTypedWhereLike()
{
Assert.AreEqual(100, GetTestTable().Single(type: typeof(T), where: new DynamicColumn("login").Like("Hoyt.%")).id);
}
/// <summary>Test typed where expression not like.</summary>
[Test]
public virtual void TestTypedWhereNotLike()
{
Assert.AreEqual(199, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("login").NotLike("Hoyt.%")));
}
/// <summary>Test typed where expression greater.</summary>
[Test]
public virtual void TestTypedWhereGt()
{
Assert.AreEqual(100, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Greater(100)));
}
/// <summary>Test typed where expression greater or equal.</summary>
[Test]
public virtual void TestTypedWhereGte()
{
Assert.AreEqual(101, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").GreaterOrEqual(100)));
}
/// <summary>Test typed where expression less.</summary>
[Test]
public virtual void TestTypedWhereLt()
{
Assert.AreEqual(99, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Less(100)));
}
/// <summary>Test typed where expression less or equal.</summary>
[Test]
public virtual void TestTypedWhereLte()
{
Assert.AreEqual(100, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").LessOrEqual(100)));
}
/// <summary>Test typed where expression between.</summary>
[Test]
public virtual void TestTypedWhereBetween()
{
Assert.AreEqual(26, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").Between(75, 100)));
}
/// <summary>Test typed where expression in params.</summary>
[Test]
public virtual void TestTypedWhereIn1()
{
Assert.AreEqual(3, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").In(75, 99, 100)));
}
/// <summary>Test typed where expression in array.</summary>
[Test]
public virtual void TestTypedWhereIn2()
{
Assert.AreEqual(3, GetTestTable().Count(type: typeof(T), where: new DynamicColumn("id").In(new[] { 75, 99, 100 })));
}
#endregion Where typed
#region Select generic
/// <summary>Test load all rows into mapped list alternate way.</summary>
[Test]
public virtual void TestGenericGetAll()
{
var list = (GetTestTable().Query<T>() as IEnumerable<object>).Cast<T>().ToList();
Assert.AreEqual(200, list.Count);
}
/// <summary>Test unknown op.</summary>
[Test]
public virtual void TestGenericUnknownOperation()
{
Assert.Throws<InvalidOperationException>(() => GetTestTable().MakeMeASandwitch<T>(with: "cheese"));
}
/// <summary>Test generic <c>Count</c> method.</summary>
[Test]
public virtual void TestGenericCount()
{
Assert.AreEqual(200, GetTestTable().Count<T>(columns: "id"));
}
/// <summary>Test count with in steatement.</summary>
[Test]
public virtual void TestGenericSelectInEnumerableCount()
{
Assert.AreEqual(4, GetTestTable().Count<T>(last: new DynamicColumn
{
Operator = DynamicColumn.CompareOperator.In,
Value = new object[] { "Hendricks", "Goodwin", "Freeman" }.Take(3)
}));
}
/// <summary>Test count with in steatement.</summary>
[Test]
public virtual void TestGenericSelectInArrayCount()
{
Assert.AreEqual(4, GetTestTable().Count<T>(last: new DynamicColumn
{
Operator = DynamicColumn.CompareOperator.In,
Value = new object[] { "Hendricks", "Goodwin", "Freeman" }
}));
}
/// <summary>Test generic <c>First</c> method.</summary>
[Test]
public virtual void TestGenericFirst()
{
Assert.AreEqual(1, GetTestTable().First<T>(columns: "id").id);
}
/// <summary>Test generic <c>Last</c> method.</summary>
[Test]
public virtual void TestGenericLast()
{
Assert.AreEqual(200, GetTestTable().Last<T>(columns: "id").id);
}
/// <summary>Test generic <c>Count</c> method.</summary>
[Test]
public virtual void TestGenericCountSpecificRecord()
{
Assert.AreEqual(1, GetTestTable().Count<T>(first: "Ori"));
}
/// <summary>Test generic <c>Min</c> method.</summary>
[Test]
public virtual void TestGenericMin()
{
Assert.AreEqual(1, GetTestTable().Min<T>(columns: "id"));
}
/// <summary>Test generic <c>Min</c> method.</summary>
[Test]
public virtual void TestGenericMax()
{
Assert.AreEqual(200, GetTestTable().Max<T>(columns: "id"));
}
/// <summary>Test generic <c>Min</c> method.</summary>
[Test]
public virtual void TestGenerictAvg()
{
Assert.AreEqual(100.5, GetTestTable().Avg<T>(columns: "id"));
}
/// <summary>Test generic <c>Sum</c> method.</summary>
[Test]
public virtual void TestGenericSum()
{
Assert.AreEqual(20100, GetTestTable().Sum<T>(columns: "id"));
}
/// <summary>Test generic <c>Scalar</c> method for invalid operation exception.</summary>
[Test]
public virtual void TestGenericScalarException()
{
Assert.Throws<InvalidOperationException>(() => GetTestTable().Scalar<T>(id: 19));
}
/// <summary>Test generic <c>Scalar</c> method.</summary>
[Test]
public virtual void TestGenericScalar()
{
Assert.AreEqual("Ori", GetTestTable().Scalar<T>(columns: "first", id: 19));
}
/// <summary>Test generic <c>Scalar</c> method with SQLite specific aggregate.</summary>
[Test]
public virtual void TestGenericScalarGroupConcat()
{
// This test should produce something like this:
// select group_concat("first") AS first from "users" where "id" < 20;
Assert.AreEqual("Clarke,Marny,Dai,Forrest,Blossom,George,Ivory,Inez,Sigourney,Fulton,Logan,Anne,Alexandra,Adena,Lionel,Aimee,Selma,Lara,Ori",
GetTestTable().Scalar<T>(columns: "first:first:group_concat", id: new DynamicColumn { Operator = DynamicColumn.CompareOperator.Lt, Value = 20 }));
}
/// <summary>Test generic <c>Scalar</c> method with SQLite specific aggregate not using aggregate field.</summary>
[Test]
public virtual void TestGenericScalarGroupConcatNoAggregateField()
{
// This test should produce something like this:
// select group_concat(first) AS first from "users" where "id" < 20;
Assert.AreEqual("Clarke,Marny,Dai,Forrest,Blossom,George,Ivory,Inez,Sigourney,Fulton,Logan,Anne,Alexandra,Adena,Lionel,Aimee,Selma,Lara,Ori",
GetTestTable().Scalar<T>(columns: "group_concat(first):first", id: new DynamicColumn { Operator = DynamicColumn.CompareOperator.Lt, Value = 20 }));
}
/// <summary>Test something fancy... like: <code>select "first", count("first") aggregatefield from "users" group by "first" order by 2 desc;</code>.</summary>
[Test]
public virtual void TestGenericFancyAggregateQuery()
{
var v = (GetTestTable().Query<T>(columns: "first,first:aggregatefield:count", group: "first", order: ":desc:2") as IEnumerable<dynamic>).ToList();
Assert.IsNotNull(v);
Assert.AreEqual(187, v.Count());
Assert.AreEqual(4, v.First().aggregatefield);
Assert.AreEqual("Logan", v.First().first);
Assert.AreEqual(2, v.Take(10).Last().aggregatefield);
Assert.AreEqual(1, v.Take(11).Last().aggregatefield);
Assert.AreEqual(1, v.Last().aggregatefield);
}
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("login")) len from "users";</code>.</summary>
[Test]
public virtual void TestGenericAggregateInAggregate()
{
Assert.AreEqual(12.77, GetTestTable().Scalar<T>(columns: @"length(""login""):len:avg"));
}
/// <summary>This time also something fancy... aggregate in aggregate <code>select AVG(LENGTH("email")) len from "users";</code>.</summary>
[Test]
public virtual void TestGenericAggregateInAggregateMark2()
{
Assert.AreEqual(27.7, GetTestTable().Avg<T>(columns: @"length(""email""):len"));
}
/// <summary>Test emails longer than 27 chars. <code>select count(*) from "users" where length("email") > 27;</code>.</summary>
public virtual void TestGenericFunctionInWhere()
{
Assert.AreEqual(97,
GetTestTable().Count<T>(condition1:
new DynamicColumn()
{
ColumnName = "email",
Aggregate = "length",
Operator = DynamicColumn.CompareOperator.Gt,
Value = 27
}));
}
/// <summary>Test generic <c>Single</c> multi.</summary>
[Test]
public virtual void TestGenericSingleObject()
{
var exp = new { id = 19, first = "Ori", last = "Ellis" };
var o = GetTestTable().Single<T>(columns: "id,first,last", id: 19);
Assert.AreEqual(exp.id, o.id);
Assert.AreEqual(exp.first, o.first);
Assert.AreEqual(exp.last, o.last);
}
#endregion Select generic
#region Where generic
/// <summary>Test generic where expression equal.</summary>
[Test]
public virtual void TestGenericWhereEq()
{
Assert.AreEqual("hoyt.tran", GetTestTable().Single<T>(where: new DynamicColumn("id").Eq(100)).login);
}
/// <summary>Test generic where expression not equal.</summary>
[Test]
public virtual void TestGenericWhereNot()
{
Assert.AreEqual(199, GetTestTable().Count<T>(where: new DynamicColumn("id").Not(100)));
}
/// <summary>Test generic where expression like.</summary>
[Test]
public virtual void TestGenericWhereLike()
{
Assert.AreEqual(100, GetTestTable().Single<T>(where: new DynamicColumn("login").Like("Hoyt.%")).id);
}
/// <summary>Test generic where expression not like.</summary>
[Test]
public virtual void TestGenericWhereNotLike()
{
Assert.AreEqual(199, GetTestTable().Count<T>(where: new DynamicColumn("login").NotLike("Hoyt.%")));
}
/// <summary>Test generic where expression greater.</summary>
[Test]
public virtual void TestGenericWhereGt()
{
Assert.AreEqual(100, GetTestTable().Count<T>(where: new DynamicColumn("id").Greater(100)));
}
/// <summary>Test generic where expression greater or equal.</summary>
[Test]
public virtual void TestGenericWhereGte()
{
Assert.AreEqual(101, GetTestTable().Count<T>(where: new DynamicColumn("id").GreaterOrEqual(100)));
}
/// <summary>Test generic where expression less.</summary>
[Test]
public virtual void TestGenericWhereLt()
{
Assert.AreEqual(99, GetTestTable().Count<T>(where: new DynamicColumn("id").Less(100)));
}
/// <summary>Test generic where expression less or equal.</summary>
[Test]
public virtual void TestGenericWhereLte()
{
Assert.AreEqual(100, GetTestTable().Count<T>(where: new DynamicColumn("id").LessOrEqual(100)));
}
/// <summary>Test generic where expression between.</summary>
[Test]
public virtual void TestGenericWhereBetween()
{
Assert.AreEqual(26, GetTestTable().Count<T>(where: new DynamicColumn("id").Between(75, 100)));
}
/// <summary>Test generic where expression in params.</summary>
[Test]
public virtual void TestGenericWhereIn1()
{
Assert.AreEqual(3, GetTestTable().Count<T>(where: new DynamicColumn("id").In(75, 99, 100)));
}
/// <summary>Test generic where expression in array.</summary>
[Test]
public virtual void TestGenericWhereIn2()
{
Assert.AreEqual(3, GetTestTable().Count<T>(where: new DynamicColumn("id").In(new[] { 75, 99, 100 })));
}
#endregion Where generic
}
}

119
DynamORM.Tests/TestsBase.cs Normal file
View File

@@ -0,0 +1,119 @@
/*
* DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012, Grzegorz Russek (grzegorz.russek@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Data;
using System.IO;
using SQLiteFactory =
#if MONO
Mono.Data.Sqlite.SqliteFactory;
#else
System.Data.SQLite.SQLiteFactory;
#endif
namespace DynamORM.Tests
{
/// <summary>Basic test utilities.</summary>
public class TestsBase
{
private string _dbpath = Path.GetTempFileName();
/// <summary>Gets or sets <see cref="DynamicDatabase"/> instance.</summary>
public DynamicDatabase Database { get; set; }
#region ADO.NET initialization
/// <summary>Prepare database with some fixed data for tests using plain old ADO.NET.</summary>
public void CreateTestDatabase()
{
Console.Out.Write("Creating database at '{0}'...", _dbpath);
using (IDbConnection conn = SQLiteFactory.Instance.CreateConnection())
{
conn.ConnectionString = string.Format("Data Source={0};", _dbpath);
conn.Open();
using (IDbTransaction trans = conn.BeginTransaction())
{
using (IDbCommand cmd = conn.CreateCommand()
.SetCommand(Properties.Resources.UsersTable)
.SetTransaction(trans))
cmd.ExecuteNonQuery();
trans.Commit();
}
}
Console.Out.WriteLine(" Done.");
}
/// <summary>Delete test database file.</summary>
public void DestroyTestDatabase()
{
File.Delete(_dbpath);
}
#endregion ADO.NET initialization
#region DynamORM Initialization
/// <summary>Create <see cref="DynamicDatabase"/> with default otions for SQLite.</summary>
public void CreateDynamicDatabase()
{
CreateDynamicDatabase(
DynamicDatabaseOptions.SingleConnection |
DynamicDatabaseOptions.SingleTransaction |
DynamicDatabaseOptions.SupportLimitOffset |
DynamicDatabaseOptions.SupportSchema);
}
/// <summary>Create <see cref="DynamicDatabase"/> with specified options.</summary>
/// <param name="options">Database options.</param>
public void CreateDynamicDatabase(DynamicDatabaseOptions options)
{
Database = new DynamicDatabase(SQLiteFactory.Instance,
string.Format("Data Source={0};", _dbpath), options)
{
DumpCommands = true
};
}
/// <summary>Dispose <see cref="DynamicDatabase"/> (and rollback if transaction exist).</summary>
public void DestroyDynamicDatabase()
{
if (Database != null)
Database.Dispose();
}
#endregion DynamORM Initialization
}
}