提交 3255ce52 编写于 作者: W Wade Baglin

Merge branch 'development'

## PetaPoco Ignores
/Tools/PetaPoco.*
/Output/PetaPoco.*
/Output/Database.*
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
......
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>PetaPoco.Core.Compiled</id>
<title>PetaPoco.Core.Compiled - A tiny ORMish thing for your POCOs (Core Only, Compiled)</title>
<version>5.0.1</version>
<authors>Collaborating Platypus</authors>
<owners>Collaborating Platypus</owners>
<licenseUrl>https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/CollaboratingPlatypus/PetaPoco</projectUrl>
<iconUrl>https://raw.githubusercontent.com/CollaboratingPlatypus/PetaPoco/master/Media/Logo2/PetaPocoLogo2Nuget.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>
PetaPoco is a tiny, single file .NET data access layer inspired by Massive that works with both non-dynamic POCO objects and dynamics.
This package includes the just the core PetaPoco library (compiled) (ie: no T4 templates)
</description>
<tags>Peta Poco Peta-Poco PetaPoco ORM-Micro Micro-ORM ORM ormmicro MVC MVC4 MVC5 MVC6 MySql Postgres MSSQL Database DAL SQL Easy</tags>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Data" />
<frameworkAssembly assemblyName="System.Configuration" />
</frameworkAssemblies>
</metadata>
<files>
<file src="v4.0\PetaPoco.dll" target="lib\net40" />
<file src="v4.0\PetaPoco.pdb" target="lib\net40" />
<file src="v4.0\PetaPoco.xml" target="lib\net40" />
<file src="v4.5\PetaPoco.dll" target="lib\net45" />
<file src="v4.5\PetaPoco.pdb" target="lib\net45" />
<file src="v4.0\PetaPoco.xml" target="lib\net45" />
<file src="v4.6\PetaPoco.dll" target="lib\net46" />
<file src="v4.6\PetaPoco.pdb" target="lib\net46" />
<file src="v4.0\PetaPoco.xml" target="lib\net46" />
</files>
</package>
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>PetaPoco.Core</id>
<title>PetaPoco.Core - A tiny ORMish thing for your POCOs (Core Only)</title>
<version>5.0.1</version>
<authors>Collaborating Platypus</authors>
<owners>Collaborating Platypus</owners>
<licenseUrl>https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/CollaboratingPlatypus/PetaPoco</projectUrl>
<iconUrl>https://raw.githubusercontent.com/CollaboratingPlatypus/PetaPoco/master/Media/Logo2/PetaPocoLogo2Nuget.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>
PetaPoco is a tiny, single file .NET data access layer inspired by Massive that works with both non-dynamic POCO objects and dynamics.
This package includes the just the core PetaPoco library (ie: no T4 templates)
</description>
<tags>Peta Poco Peta-Poco PetaPoco ORM-Micro Micro-ORM ORM ormmicro MVC MVC4 MVC5 MVC6 MySql Postgres MSSQL Database DAL SQL Easy</tags>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Data" />
<frameworkAssembly assemblyName="System.Configuration" />
</frameworkAssemblies>
</metadata>
<files>
<file src="PetaPoco.cs" target="Content\Models" />
</files>
</package>
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>PetaPoco</id>
<title>PetaPoco - A tiny ORMish thing for your POCOs (Core + T4 Templates)</title>
<version>5.0.1</version>
<authors>Collaborating Platypus</authors>
<owners>Collaborating Platypus</owners>
<licenseUrl>https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/CollaboratingPlatypus/PetaPoco</projectUrl>
<iconUrl>https://raw.githubusercontent.com/CollaboratingPlatypus/PetaPoco/master/Media/Logo2/PetaPocoLogo2Nuget.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>
PetaPoco is a tiny, single file .NET data access layer inspired by Massive that works with both non-dynamic POCO objects and dynamics.
This package includes the core PetaPoco library + T4 templates to generate POCO classes from your database
</description>
<tags>Peta Poco Peta-Poco PetaPoco ORM-Micro Micro-ORM ORM ormmicro MVC MVC4 MVC5 MVC6 MySql Postgres MSSQL Database DAL SQL Easy</tags>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Data" />
<frameworkAssembly assemblyName="System.Configuration" />
</frameworkAssemblies>
</metadata>
<files>
<file src="PetaPoco.cs" target="Content\Models" />
<file src="*.tt" target="Content\Models\Generated" />
<file src="PetaPoco*.ttinclude" target="Content\Models\Generated" />
</files>
</package>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{53F07078-98EA-4494-9829-74245992A7F1}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PetaPoco.Cs.Joiner</RootNamespace>
<AssemblyName>PetaPoco.Cs.Joiner</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\Tools\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>PetaPoco.Cs.Joiner.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\Tools\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>PetaPoco.Cs.Joiner.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<CodeAnalysisRuleSet>PetaPoco.Cs.Joiner.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<CodeAnalysisRuleSet>PetaPoco.Cs.Joiner.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="PetaPoco.Cs.Joiner.ruleset" />
</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>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>/?</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>"C:\Projects\Open Source\PetaPoco\PetaPoco\\"</StartArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for PetaPoco.Cs.Joiner" Description="Code analysis rules for PetaPoco.Cs.Joiner.csproj." ToolsVersion="14.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />
<Rule Id="CA1400" Action="Warning" />
<Rule Id="CA1401" Action="Warning" />
<Rule Id="CA1403" Action="Warning" />
<Rule Id="CA1404" Action="Warning" />
<Rule Id="CA1405" Action="Warning" />
<Rule Id="CA1410" Action="Warning" />
<Rule Id="CA1415" Action="Warning" />
<Rule Id="CA1821" Action="Warning" />
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA1901" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2101" Action="Warning" />
<Rule Id="CA2108" Action="Warning" />
<Rule Id="CA2111" Action="Warning" />
<Rule Id="CA2112" Action="Warning" />
<Rule Id="CA2114" Action="Warning" />
<Rule Id="CA2116" Action="Warning" />
<Rule Id="CA2117" Action="Warning" />
<Rule Id="CA2122" Action="Warning" />
<Rule Id="CA2123" Action="Warning" />
<Rule Id="CA2124" Action="Warning" />
<Rule Id="CA2126" Action="Warning" />
<Rule Id="CA2131" Action="Warning" />
<Rule Id="CA2132" Action="Warning" />
<Rule Id="CA2133" Action="Warning" />
<Rule Id="CA2134" Action="Warning" />
<Rule Id="CA2137" Action="Warning" />
<Rule Id="CA2138" Action="Warning" />
<Rule Id="CA2140" Action="Warning" />
<Rule Id="CA2141" Action="Warning" />
<Rule Id="CA2146" Action="Warning" />
<Rule Id="CA2147" Action="Warning" />
<Rule Id="CA2149" Action="Warning" />
<Rule Id="CA2200" Action="Warning" />
<Rule Id="CA2202" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2220" Action="Warning" />
<Rule Id="CA2229" Action="Warning" />
<Rule Id="CA2231" Action="Warning" />
<Rule Id="CA2232" Action="Warning" />
<Rule Id="CA2235" Action="Warning" />
<Rule Id="CA2236" Action="Warning" />
<Rule Id="CA2237" Action="Warning" />
<Rule Id="CA2238" Action="Warning" />
<Rule Id="CA2240" Action="Warning" />
<Rule Id="CA2241" Action="Warning" />
<Rule Id="CA2242" Action="Warning" />
</Rules>
<Rules AnalyzerId="RefactoringEssentials" RuleNamespace="RefactoringEssentials">
<Rule Id="RECS0145" Action="None" />
</Rules>
</RuleSet>
\ No newline at end of file
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace PetaPoco.Cs.Joiner
{
public class Program
{
private static int Main(string[] args)
{
if (args == null || args.Length != 1)
{
Console.WriteLine("Invalid argument. A signle argument is required, which must be the PetaPoco directory.");
return 9;
}
var filePath = Path.GetFullPath(args[0]);
var databaseFilePath = Path.Combine(filePath, "Database.cs");
if (!File.Exists(databaseFilePath))
{
Console.WriteLine($"PetaPoco not found at `${databaseFilePath}`.");
return 9;
}
var files = Directory.GetFiles(filePath, "*.cs", SearchOption.AllDirectories)
.Where(f => f.IndexOf("AssemblyInfo.cs", StringComparison.OrdinalIgnoreCase) < 0)
.ToArray();
var parsedFiles = files
.Select(f => CsFile.Parse(File.ReadAllText(f)))
.ToList();
var builder = new StringBuilder();
builder.Append(@"// <copyright file=""ColumnAttribute.cs"" company=""PetaPoco - CollaboratingPlatypus"">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>")
.Append(DateTime.Now.ToString("yyyy/MM/dd"))
.AppendLine(@"</date>
// --------------------------WARNING--------------------------------
// -----------------------------------------------------------------
// This file was built by merging separate C# source files into one.
// DO NOT EDIT THIS FILE. Any edits will be overwritten when the
// nuget package is updated or reinstalled. If changes are required
// extend the Database class and place in a separate file.
// -----------------------------------------------------------------
// --------------------------WARNING--------------------------------
");
var usings = parsedFiles
.SelectMany(pf => pf.Usings)
.Where(u => u.IndexOf("PetaPoco", StringComparison.OrdinalIgnoreCase) < 0)
.Distinct(StringComparer.Ordinal)
.OrderBy(s => s)
.ToList();
usings.ForEach(u => builder.AppendLine(u));
builder.AppendLine(@"
namespace PetaPoco
{
#pragma warning disable 1066,1570,1573,1591");
parsedFiles.ForEach(p => builder.AppendLine(p.CodeBlock));
builder.Append(@"#pragma warning restore 1066,1570,1573,1591
}");
File.WriteAllText(Path.Combine(filePath, "..\\", "Output", "PetaPoco.cs"), builder.ToString());
return 0;
}
public class CsFile
{
private static Regex _usingsRegex = new Regex("using\\s.+?;", RegexOptions.CultureInvariant| RegexOptions.Compiled);
private static Regex _codeBlockRegex = new Regex("(?<=namespace\\s.+?{).+?(?=}\\s*$)", RegexOptions.Singleline | RegexOptions.CultureInvariant| RegexOptions.Compiled);
public string[] Usings { get; private set; }
public string CodeBlock { get; private set; }
public static CsFile Parse(string fileContents)
{
return new CsFile
{
Usings = _usingsRegex.Matches(fileContents)
.Cast<Match>().Select(m => m.Value).ToArray(),
CodeBlock = _codeBlockRegex.Match(fileContents).Value
};
}
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
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("csj")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("csj")]
[assembly: AssemblyCopyright("Copyright © 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("6d7a7154-7f3c-4335-941f-7840f96c8c46")]
// 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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="mysql" connectionString="server=jab;database=jab;user id=jab;password=jab;Allow User Variables=true" providerName="MySql.Data.MySqlClient"/>
<add name="sqlserver" connectionString="Data Source=MACBOOK\SQLEXPRESS;Initial Catalog=testdb;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="sqlserverce" connectionString="Data Source=C:\Users\bradr\dev\Source\PetaPoco\PetaPoco.Tests\petapoco.sdf" providerName="System.Data.SqlServerCe.4.0"/>
<add name="postgresql" connectionString="Server=127.0.0.1;User id=postgres;password=password01;Database=tempdb;" providerName="Npgsql"/>
</connectionStrings>
<!--system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.11.91, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data-->
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaTest;
using PetaPoco;
namespace PetaPoco.Tests
{
public class MultiPocoTests
{
[TableName("posts")]
[PrimaryKey("id")]
public class post
{
public long id { get; set; }
public string title { get; set; }
public long author { get; set; }
[ResultColumn] public author author_obj { get; set; }
}
[TableName("authors")]
[PrimaryKey("id")]
public class author
{
public long id { get; set; }
public string name { get; set; }
[ResultColumn]
public List<post> posts { get; set; }
}
public MultiPocoTests()
{
_connectionStringName = "mysql";
}
string _connectionStringName;
Database db;
[TestFixtureSetUp]
public void CreateDB()
{
db = new Database(_connectionStringName);
db.Execute(@"
DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS authors;
CREATE TABLE posts (
id bigint AUTO_INCREMENT NOT NULL,
title varchar(127) NOT NULL,
author bigint NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE authors (
id bigint AUTO_INCREMENT NOT NULL,
name varchar(127) NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
");
var a1 = new author();
a1.name = "Bill";
db.Insert(a1);
var a2 = new author();
a2.name = "Ted";
db.Insert(a2);
var p = new post();
p.title = "post1";
p.author = a1.id;
db.Insert(p);
p = new post();
p.title = "post2";
p.author = a1.id;
db.Insert(p);
p = new post();
p.title = "post3";
p.author = a2.id;
db.Insert(p);
}
[TestFixtureTearDown]
public void DeleteDB()
{
db.Execute(@"
DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS authors;
");
}
[Test]
public void Basic()
{
var posts = db.Fetch<post, author>("SELECT * FROM posts LEFT JOIN authors ON posts.author = authors.id ORDER BY posts.id");
Assert.AreEqual(posts.Count, 3);
Assert.AreEqual(posts[0].id, 1);
Assert.AreEqual(posts[0].title, "post1");
Assert.AreEqual(posts[0].author, 1);
Assert.AreEqual(posts[0].author_obj.name, "Bill");
Assert.AreEqual(posts[1].id, 2);
Assert.AreEqual(posts[1].title, "post2");
Assert.AreEqual(posts[1].author, 1);
Assert.AreEqual(posts[1].author_obj.name, "Bill");
Assert.AreEqual(posts[2].id, 3);
Assert.AreEqual(posts[2].title, "post3");
Assert.AreEqual(posts[2].author, 2);
Assert.AreEqual(posts[2].author_obj.name, "Ted");
}
[Test]
public void CustomRelator()
{
var posts = db.Fetch<post, author, post>(
(p,a)=>
{
p.author_obj = a;
return p;
},
"SELECT * FROM posts LEFT JOIN authors ON posts.author = authors.id ORDER BY posts.id");
Assert.AreEqual(posts.Count, 3);
Assert.AreNotSame(posts[0].author_obj, posts[1].author_obj);
Assert.AreEqual(posts[0].id, 1);
Assert.AreEqual(posts[0].title, "post1");
Assert.AreEqual(posts[0].author, 1);
Assert.AreEqual(posts[0].author_obj.name, "Bill");
Assert.AreEqual(posts[1].id, 2);
Assert.AreEqual(posts[1].title, "post2");
Assert.AreEqual(posts[1].author, 1);
Assert.AreEqual(posts[1].author_obj.name, "Bill");
Assert.AreEqual(posts[2].id, 3);
Assert.AreEqual(posts[2].title, "post3");
Assert.AreEqual(posts[2].author, 2);
Assert.AreEqual(posts[2].author_obj.name, "Ted");
}
// Relator callback to do many to one relationship mapping
class PostAuthorRelator
{
// A dictionary of known authors
Dictionary<long, author> authors = new Dictionary<long, author>();
public post MapIt(post p, author a)
{
// Get existing author object, or if not found store this one
author aExisting;
if (authors.TryGetValue(a.id, out aExisting))
a = aExisting;
else
authors.Add(a.id, a);
// Wire up objects
p.author_obj = a;
return p;
}
}
[Test]
public void ManyToOne()
{
// This test uses a custom relator callback to connect posts to existing author instances
// Note that for each row, an author object is still created - it's just that the duplicates
// are discarded
var posts = db.Fetch<post, author, post>(new PostAuthorRelator().MapIt,
"SELECT * FROM posts LEFT JOIN authors ON posts.author = authors.id ORDER BY posts.id"
);
Assert.AreEqual(posts.Count, 3);
Assert.AreSame(posts[0].author_obj, posts[1].author_obj);
Assert.AreEqual(posts[0].id, 1);
Assert.AreEqual(posts[0].title, "post1");
Assert.AreEqual(posts[0].author, 1);
Assert.AreEqual(posts[0].author_obj.name, "Bill");
Assert.AreEqual(posts[1].id, 2);
Assert.AreEqual(posts[1].title, "post2");
Assert.AreEqual(posts[1].author, 1);
Assert.AreEqual(posts[1].author_obj.name, "Bill");
Assert.AreEqual(posts[2].id, 3);
Assert.AreEqual(posts[2].title, "post3");
Assert.AreEqual(posts[2].author, 2);
Assert.AreEqual(posts[2].author_obj.name, "Ted");
}
class AuthorPostRelator
{
/*
* In order to support OneToMany relationship mapping, we need to be able to
* delay returning an LHS object until we've processed its many RHS objects
*
* To support this, PetaPoco allows a relator callback to return null - indicating
* that the object isn't yet fully populated.
*
* In order to flush the final object, PetaPoco will call the relator function
* one final time with all parameters set to null. It only does this if the callback
* returned null at least once during the processing of the result set (this saves
* simple lamba mapping functions from having to deal with nulls).
*
*/
public author current;
public author MapIt(author a, post p)
{
// Terminating call. Since we can return null from this function
// we need to be ready for PetaPoco to callback later with null
// parameters
if (a == null)
return current;
// Is this the same author as the current one we're processing
if (current != null && current.id == a.id)
{
// Yes, just add this post to the current author's collection of posts
current.posts.Add(p);
// Return null to indicate we're not done with this author yet
return null;
}
// This is a different author to the current one, or this is the
// first time through and we don't have an author yet
// Save the current author
var prev = current;
// Setup the new current author
current = a;
current.posts = new List<post>();
current.posts.Add(p);
// Return the now populated previous author (or null if first time through)
return prev;
}
}
[Test]
public void OneToMany()
{
// Example of OneToMany mappings
var authors = db.Fetch<author, post, author>(new AuthorPostRelator().MapIt,
"SELECT * FROM authors LEFT JOIN posts ON posts.author = authors.id ORDER BY posts.id"
);
Assert.AreEqual(authors.Count, 2);
Assert.AreEqual(authors[0].name, "Bill");
Assert.AreEqual(authors[0].posts.Count, 2);
Assert.AreEqual(authors[0].posts[0].title, "post1");
Assert.AreEqual(authors[0].posts[1].title, "post2");
Assert.AreEqual(authors[1].name, "Ted");
Assert.AreEqual(authors[1].posts.Count, 1);
Assert.AreEqual(authors[1].posts[0].title, "post3");
}
[Test]
public void ManyToOne_Lambda()
{
// same as ManyToOne test case above, but uses a lambda method as the callback
var authors = new Dictionary<long, author>();
var posts = db.Fetch<post, author, post>(
(p, a) =>
{
// Get existing author object
author aExisting;
if (authors.TryGetValue(a.id, out aExisting))
a = aExisting;
else
authors.Add(a.id, a);
// Wire up objects
p.author_obj = a;
return p;
},
"SELECT * FROM posts LEFT JOIN authors ON posts.author = authors.id ORDER BY posts.id"
);
Assert.AreEqual(posts.Count, 3);
Assert.AreSame(posts[0].author_obj, posts[1].author_obj);
Assert.AreEqual(posts[0].id, 1);
Assert.AreEqual(posts[0].title, "post1");
Assert.AreEqual(posts[0].author, 1);
Assert.AreEqual(posts[0].author_obj.name, "Bill");
Assert.AreEqual(posts[1].id, 2);
Assert.AreEqual(posts[1].title, "post2");
Assert.AreEqual(posts[1].author, 1);
Assert.AreEqual(posts[1].author_obj.name, "Bill");
Assert.AreEqual(posts[2].id, 3);
Assert.AreEqual(posts[2].title, "post3");
Assert.AreEqual(posts[2].author, 2);
Assert.AreEqual(posts[2].author_obj.name, "Ted");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{E6787C52-7549-44CD-AA6E-AB9D55946AB9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PetaPoco.Tests</RootNamespace>
<AssemblyName>PetaPoco.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</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>
<PropertyGroup>
<StartupObject>PetaPoco.Tests.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files\Microsoft SQL Server Compact Edition\v4.0\Desktop\System.Data.SqlServerCe.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="MultiPocoTests.cs" />
<Compile Include="PetaTest.cs" />
<Compile Include="Program.cs" />
<Compile Include="poco.cs" />
<Compile Include="Tests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="mysql_init.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="mysql_done.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="sqlserver_init.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="sqlserver_done.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="postgresql_done.sql" />
<EmbeddedResource Include="postgresql_init.sql" />
<Content Include="petapoco.sdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="sqlserverce_init.sql" />
<EmbeddedResource Include="sqlserverce_done.sql" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PetaPoco\PetaPoco.csproj">
<Project>{33699753-151D-4100-8F12-9AE1AEB5C5BD}</Project>
<Name>PetaPoco</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>
\ No newline at end of file
此差异已折叠。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PetaPoco.Tests
{
public class Program
{
public static void Main(string[] args)
{
PetaTest.Runner.RunMain(args);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
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("PetaPoco.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("PetaPoco.Tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[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("bf137eb0-bec8-4b7e-819b-707cfc196c66")]
// 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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaTest;
using PetaPoco;
namespace PetaPoco.Tests
{
[TestFixture("sqlserver")]
[TestFixture("sqlserverce")]
[TestFixture("mysql")]
[TestFixture("postgresql")]
public class Tests
{
public Tests(string connectionStringName)
{
_connectionStringName = connectionStringName;
}
string _connectionStringName;
Random r = new Random();
Database db;
[TestFixtureSetUp]
public void CreateDB()
{
db = new Database(_connectionStringName);
db.OpenSharedConnection(); // <-- Wow, this is crucial to getting SqlCE to perform.
db.Execute(Utils.LoadTextResource(string.Format("PetaPoco.Tests.{0}_init.sql", _connectionStringName)));
}
[TestFixtureTearDown]
public void DeleteDB()
{
db.Execute(Utils.LoadTextResource(string.Format("PetaPoco.Tests.{0}_done.sql", _connectionStringName)));
}
long GetRecordCount()
{
return db.ExecuteScalar<long>("SELECT COUNT(*) FROM petapoco");
}
[TearDown]
public void Teardown()
{
// Delete everything
db.Delete<deco>("");
db.Delete<petapoco2>("");
// Should be clean
Assert.AreEqual(GetRecordCount(), 0);
}
poco CreatePoco()
{
// Need a rounded date as DB can't store millis
var now = DateTime.UtcNow;
now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
// Setup a record
var o = new poco();
o.title = string.Format("insert {0}", r.Next());
o.draft = true;
o.content = string.Format("insert {0}", r.Next());
o.date_created = now;
o.date_edited = now;
o.state = State.Yes;
o.col_w_space = 23;
o.nullreal = 24;
return o;
}
deco CreateDeco()
{
// Need a rounded date as DB can't store millis
var now = DateTime.UtcNow;
now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
// Setup a record
var o = new deco();
o.title = string.Format("insert {0}", r.Next());
o.draft = true;
o.content = string.Format("insert {0}", r.Next());
o.date_created = now;
o.date_edited = now;
o.state = State.Maybe;
o.col_w_space = 23;
o.nullreal = 24;
return o;
}
void AssertPocos(poco a, poco b)
{
Assert.AreEqual(a.id, b.id);
Assert.AreEqual(a.title, b.title);
Assert.AreEqual(a.draft, b.draft);
Assert.AreEqual(a.content, b.content);
Assert.AreEqual(a.date_created, b.date_created);
Assert.AreEqual(a.date_edited, b.date_edited);
Assert.AreEqual(a.state, b.state);
Assert.AreEqual(a.col_w_space, b.col_w_space);
Assert.AreEqual(a.nullreal, b.nullreal);
}
void AssertPocos(deco a, deco b)
{
Assert.AreEqual(a.id, b.id);
Assert.AreEqual(a.title, b.title);
Assert.AreEqual(a.draft, b.draft);
Assert.AreEqual(a.content, b.content);
Assert.AreEqual(a.date_created, b.date_created);
Assert.AreEqual(a.state, b.state);
Assert.AreEqual(a.col_w_space, b.col_w_space);
Assert.AreEqual(a.nullreal, b.nullreal);
}
// Insert some records, return the id of the first
long InsertRecords(int count)
{
long lFirst = 0;
for (int i = 0; i < count; i++)
{
var o=CreatePoco();
db.Insert("petapoco", "id", o);
var lc = db.LastCommand;
if (i == 0)
{
lFirst = o.id;
Assert.AreNotEqual(o.id, 0);
}
}
return lFirst;
}
[Test]
public void poco_Crud()
{
// Create a random record
var o = CreatePoco();
Assert.IsTrue(db.IsNew("id", o));
// Insert it
db.Insert("petapoco", "id", o);
Assert.AreNotEqual(o.id, 0);
Assert.IsFalse(db.IsNew("id", o));
// Retrieve it
var o2 = db.Single<poco>("SELECT * FROM petapoco WHERE id=@0", o.id);
Assert.IsFalse(db.IsNew("id", o2));
// Check it
AssertPocos(o, o2);
// Update it
o2.title = "New Title";
db.Save("petapoco", "id", o2);
// Retrieve itagain
var o3 = db.Single<poco>("SELECT * FROM petapoco WHERE id=@0", o.id);
// Check it
AssertPocos(o2, o3);
// Delete it
db.Delete("petapoco", "id", o3);
// Should be gone!
var o4 = db.SingleOrDefault<poco>("SELECT * FROM petapoco WHERE id=@0", o.id);
Assert.IsNull(o4);
}
[Test]
public void deco_Crud()
{
// Create a random record
var o = CreateDeco();
Assert.IsTrue(db.IsNew(o));
// Insert it
db.Insert(o);
Assert.AreNotEqual(o.id, 0);
Assert.IsFalse(db.IsNew(o));
// Retrieve it
var o2 = db.Single<deco>("SELECT * FROM petapoco WHERE id=@0", o.id);
Assert.IsFalse(db.IsNew(o2));
// Check it
AssertPocos(o, o2);
// Update it
o2.title = "New Title";
db.Save(o2);
// Retrieve itagain
var o3 = db.Single<deco>("SELECT * FROM petapoco WHERE id=@0", o.id);
// Check it
AssertPocos(o2, o3);
// Delete it
db.Delete(o3);
// Should be gone!
var o4 = db.SingleOrDefault<deco>("SELECT * FROM petapoco WHERE id=@0", o.id);
Assert.IsNull(o4);
}
[Test]
public void Fetch()
{
// Create some records
const int count = 5;
long id = InsertRecords(count);
// Fetch em
var r = db.Fetch<poco>("SELECT * from petapoco ORDER BY id");
Assert.AreEqual(r.Count, count);
// Check em
for (int i = 0; i < count; i++)
{
Assert.AreEqual(r[i].id, id + i);
}
}
[Test]
public void Query()
{
// Create some records
const int count = 5;
long id = InsertRecords(count);
// Fetch em
var r = db.Query<poco>("SELECT * from petapoco ORDER BY id");
// Check em
int i = 0;
foreach (var p in r)
{
Assert.AreEqual(p.id, id + i);
i++;
}
Assert.AreEqual(i, count);
}
[Test]
public void Page()
{
// In this test we're checking that the page count is correct when there are
// not-exactly pagesize*N records (ie: a partial page at the end)
// Create some records
const int count = 13;
long id = InsertRecords(count);
// Fetch em
var r = db.Page<poco>(2, 5, "SELECT * from petapoco ORDER BY id");
// Check em
int i = 0;
foreach (var p in r.Items)
{
Assert.AreEqual(p.id, id + i + 5);
i++;
}
// Check other stats
Assert.AreEqual(r.Items.Count, 5);
Assert.AreEqual(r.CurrentPage, 2);
Assert.AreEqual(r.ItemsPerPage, 5);
Assert.AreEqual(r.TotalItems, 13);
Assert.AreEqual(r.TotalPages, 3);
}
[Test]
public void Page_NoOrderBy()
{
// Unordered paging not supported by Compact Edition
if (_connectionStringName == "sqlserverce")
return;
// In this test we're checking that the page count is correct when there are
// not-exactly pagesize*N records (ie: a partial page at the end)
// Create some records
const int count = 13;
long id = InsertRecords(count);
// Fetch em
var r = db.Page<poco>(2, 5, "SELECT * from petapoco");
// Check em
int i = 0;
foreach (var p in r.Items)
{
Assert.AreEqual(p.id, id + i + 5);
i++;
}
// Check other stats
Assert.AreEqual(r.Items.Count, 5);
Assert.AreEqual(r.CurrentPage, 2);
Assert.AreEqual(r.ItemsPerPage, 5);
Assert.AreEqual(r.TotalItems, 13);
Assert.AreEqual(r.TotalPages, 3);
}
[Test]
public void Page_Distinct()
{
// Unordered paging not supported by Compact Edition
if (_connectionStringName == "sqlserverce")
return;
// In this test we're checking that the page count is correct when there are
// not-exactly pagesize*N records (ie: a partial page at the end)
// Create some records
const int count = 13;
long id = InsertRecords(count);
// Fetch em
var r = db.Page<poco>(2, 5, "SELECT DISTINCT id from petapoco ORDER BY id");
// Check em
int i = 0;
foreach (var p in r.Items)
{
Assert.AreEqual(p.id, id + i + 5);
i++;
}
// Check other stats
Assert.AreEqual(r.Items.Count, 5);
Assert.AreEqual(r.CurrentPage, 2);
Assert.AreEqual(r.ItemsPerPage, 5);
Assert.AreEqual(r.TotalItems, 13);
Assert.AreEqual(r.TotalPages, 3);
}
[Test]
public void FetchPage()
{
// Create some records
const int count = 13;
long id = InsertRecords(count);
// Fetch em
var r = db.Fetch<poco>(2, 5, "SELECT * from petapoco ORDER BY id");
// Check em
int i = 0;
foreach (var p in r)
{
Assert.AreEqual(p.id, id + i + 5);
i++;
}
// Check other stats
Assert.AreEqual(r.Count, 5);
}
[Test]
public void Page_boundary()
{
// In this test we're checking that the page count is correct when there are
// exactly pagesize*N records.
// Create some records
const int count = 15;
long id = InsertRecords(count);
// Fetch em
var r = db.Page<poco>(3, 5, "SELECT * from petapoco ORDER BY id");
// Check other stats
Assert.AreEqual(r.Items.Count, 5);
Assert.AreEqual(r.CurrentPage, 3);
Assert.AreEqual(r.ItemsPerPage, 5);
Assert.AreEqual(r.TotalItems, 15);
Assert.AreEqual(r.TotalPages, 3);
}
[Test]
public void deco_Delete()
{
// Create some records
const int count = 15;
long id = InsertRecords(count);
// Delete some
db.Delete<deco>("WHERE id>=@0", id + 5);
// Check they match
Assert.AreEqual(GetRecordCount(), 5);
}
[Test]
public void deco_Update()
{
// Create some records
const int count = 15;
long id = InsertRecords(count);
// Update some
db.Update<deco>("SET title=@0 WHERE id>=@1", "zap", id + 5);
// Check some updated
foreach (var d in db.Query<deco>("ORDER BY Id"))
{
if (d.id >= id + 5)
{
Assert.AreEqual(d.title, "zap");
}
else
{
Assert.AreNotEqual(d.title, "zap");
}
}
}
[Test]
public void deco_ExplicitAttribute()
{
// Create a records
long id = InsertRecords(1);
// Retrieve it in two different ways
var a = db.SingleOrDefault<deco>("WHERE id=@0", id);
var b = db.SingleOrDefault<deco_explicit>("WHERE id=@0", id);
var c = db.SingleOrDefault<deco_explicit>("SELECT * FROM petapoco WHERE id=@0", id);
// b record should have ignored the content
Assert.IsNotNull(a.content);
Assert.IsNull(b.content);
Assert.IsNull(c.content);
}
[Test]
public void deco_IgnoreAttribute()
{
// Create a records
long id = InsertRecords(1);
// Retrieve it in two different ways
var a = db.SingleOrDefault<deco>("WHERE id=@0", id);
var b = db.SingleOrDefault<deco_non_explicit>("WHERE id=@0", id);
var c = db.SingleOrDefault<deco_non_explicit>("SELECT * FROM petapoco WHERE id=@0", id);
// b record should have ignored the content
Assert.IsNotNull(a.content);
Assert.IsNull(b.content);
Assert.IsNull(c.content);
}
[Test]
public void Transaction_complete()
{
using (var scope = db.GetTransaction())
{
InsertRecords(10);
scope.Complete();
}
Assert.AreEqual(GetRecordCount(), 10);
}
[Test]
public void Transaction_cancelled()
{
using (var scope = db.GetTransaction())
{
InsertRecords(10);
}
Assert.AreEqual(GetRecordCount(), 0);
}
[Test]
public void Transaction_nested_nn()
{
using (var scope1 = db.GetTransaction())
{
InsertRecords(10);
using (var scope2 = db.GetTransaction())
{
InsertRecords(10);
}
}
Assert.AreEqual(GetRecordCount(), 0);
}
[Test]
public void Transaction_nested_yn()
{
using (var scope1 = db.GetTransaction())
{
InsertRecords(10);
using (var scope2 = db.GetTransaction())
{
InsertRecords(10);
}
scope1.Complete();
}
Assert.AreEqual(GetRecordCount(), 0);
}
[Test]
public void Transaction_nested_ny()
{
using (var scope1 = db.GetTransaction())
{
InsertRecords(10);
using (var scope2 = db.GetTransaction())
{
InsertRecords(10);
scope2.Complete();
}
}
Assert.AreEqual(GetRecordCount(), 0);
}
[Test]
public void Transaction_nested_yy()
{
using (var scope1 = db.GetTransaction())
{
InsertRecords(10);
using (var scope2 = db.GetTransaction())
{
InsertRecords(10);
scope2.Complete();
}
scope1.Complete();
}
Assert.AreEqual(GetRecordCount(), 20);
}
[Test]
public void Transaction_nested_yny()
{
using (var scope1 = db.GetTransaction())
{
InsertRecords(10);
using (var scope2 = db.GetTransaction())
{
InsertRecords(10);
//scope2.Complete();
}
using (var scope3 = db.GetTransaction())
{
InsertRecords(10);
scope3.Complete();
}
scope1.Complete();
}
Assert.AreEqual(GetRecordCount(), 0);
}
[Test]
public void DateTimesAreUtc()
{
var id = InsertRecords(1);
var a2 = db.SingleOrDefault<deco>("WHERE id=@0", id);
Assert.AreEqual(a2.date_created.Kind, DateTimeKind.Utc);
Assert.AreEqual(a2.date_edited.Value.Kind, DateTimeKind.Utc);
}
[Test]
public void DateTimeNullable()
{
// Need a rounded date as DB can't store millis
var now = DateTime.UtcNow;
now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
// Setup a record
var a = new deco();
a.title = string.Format("insert {0}", r.Next());
a.draft = true;
a.content = string.Format("insert {0}", r.Next());
a.date_created = now;
a.date_edited = null;
db.Insert(a);
// Retrieve it
var b = db.SingleOrDefault<deco>("WHERE id=@0", a.id);
Assert.AreEqual(b.id, a.id);
Assert.AreEqual(b.date_edited.HasValue, false);
// Update it to NULL
b.date_edited = now;
db.Update(b);
var c = db.SingleOrDefault<deco>("WHERE id=@0", a.id);
Assert.AreEqual(c.id, a.id);
Assert.AreEqual(c.date_edited.HasValue, true);
// Update it to not NULL
c.date_edited = null;
db.Update(c);
var d = db.SingleOrDefault<deco>("WHERE id=@0", a.id);
Assert.AreEqual(d.id, a.id);
Assert.AreEqual(d.date_edited.HasValue, false);
}
[Test]
public void NamedArgs()
{
long first=InsertRecords(10);
var items=db.Fetch<deco>("WHERE id >= @min_id AND id <= @max_id",
new
{
min_id = first + 3,
max_id = first + 6
}
);
Assert.AreEqual(items.Count, 4);
}
[Test]
public void SingleOrDefault_Empty()
{
Assert.IsNull(db.SingleOrDefault<deco>("WHERE id=@0", 0));
}
[Test]
public void SingleOrDefault_Single()
{
var id = InsertRecords(1);
Assert.IsNotNull(db.SingleOrDefault<deco>("WHERE id=@0", id));
}
[Test]
public void SingleOrDefault_Multiple()
{
Assert.Throws<InvalidOperationException>(() =>
{
var id = InsertRecords(2);
db.SingleOrDefault<deco>("WHERE id>=@0", id);
});
}
[Test]
public void FirstOrDefault_Empty()
{
Assert.IsNull(db.FirstOrDefault<deco>("WHERE id=@0", 0));
}
[Test]
public void FirstOrDefault_First()
{
var id = InsertRecords(1);
Assert.IsNotNull(db.FirstOrDefault<deco>("WHERE id=@0", id));
}
[Test]
public void FirstOrDefault_Multiple()
{
var id = InsertRecords(2);
Assert.IsNotNull(db.FirstOrDefault<deco>("WHERE id>=@0", id));
}
[Test]
public void Single_Empty()
{
Assert.Throws<InvalidOperationException>(() =>
{
db.Single<deco>("WHERE id=@0", 0);
});
}
[Test]
public void Single_Single()
{
var id = InsertRecords(1);
Assert.IsNotNull(db.Single<deco>("WHERE id=@0", id));
}
[Test]
public void Single_Multiple()
{
Assert.Throws<InvalidOperationException>(() =>
{
var id = InsertRecords(2);
db.Single<deco>("WHERE id>=@0", id);
});
}
[Test]
public void First_Empty()
{
Assert.Throws<InvalidOperationException>(() =>
{
db.First<deco>("WHERE id=@0", 0);
});
}
[Test]
public void First_First()
{
var id = InsertRecords(1);
Assert.IsNotNull(db.First<deco>("WHERE id=@0", id));
}
[Test]
public void First_Multiple()
{
var id = InsertRecords(2);
Assert.IsNotNull(db.First<deco>("WHERE id>=@0", id));
}
[Test]
public void SingleOrDefault_PK_Empty()
{
Assert.IsNull(db.SingleOrDefault<deco>(0));
}
[Test]
public void SingleOrDefault_PK_Single()
{
var id = InsertRecords(1);
Assert.IsNotNull(db.SingleOrDefault<deco>(id));
}
[Test]
public void Single_PK_Empty()
{
Assert.Throws<InvalidOperationException>(() =>
{
db.Single<deco>(0);
});
}
[Test]
public void Single_PK_Single()
{
var id = InsertRecords(1);
Assert.IsNotNull(db.Single<deco>(id));
}
[Test]
public void AutoSelect_SelectPresent()
{
var id = InsertRecords(1);
var a = db.SingleOrDefault<deco>("SELECT * FROM petapoco WHERE id=@0", id);
Assert.IsNotNull(a);
Assert.AreEqual(a.id, id);
}
[Test]
public void AutoSelect_SelectMissingFromMissing()
{
var id = InsertRecords(1);
var a = db.SingleOrDefault<deco>("WHERE id=@0", id);
Assert.IsNotNull(a);
Assert.AreEqual(a.id, id);
}
[Test]
public void AutoSelect_SelectMissingFromPresent()
{
var id = InsertRecords(1);
var a = db.SingleOrDefault<deco>("FROM petapoco WHERE id=@0", id);
Assert.IsNotNull(a);
Assert.AreEqual(a.id, id);
}
void AssertDynamic(dynamic a, dynamic b)
{
Assert.AreEqual(a.id, b.id);
Assert.AreEqual(a.title, b.title);
Assert.AreEqual(a.draft, b.draft);
Assert.AreEqual(a.content, b.content);
Assert.AreEqual(a.date_created, b.date_created);
Assert.AreEqual(a.state, b.state);
}
dynamic CreateExpando()
{
// Need a rounded date as DB can't store millis
var now = DateTime.UtcNow;
now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
// Setup a record
dynamic o = new System.Dynamic.ExpandoObject();
o.title = string.Format("insert {0}", r.Next());
o.draft = true;
o.content = string.Format("insert {0}", r.Next());
o.date_created = now;
o.date_edited = now;
o.state = (int)State.Maybe;
return o;
}
[Test]
public void Dynamic_Query()
{
// Create a random record
var o = CreateExpando();
Assert.IsTrue(db.IsNew("id", o));
// Insert it
db.Insert("petapoco", "id", o);
Assert.AreNotEqual(o.id, 0);
Assert.IsFalse(db.IsNew("id", o));
// Retrieve it
var o2 = db.Single<dynamic>("SELECT * FROM petapoco WHERE id=@0", o.id);
Assert.IsFalse(db.IsNew("id", o2));
// Check it
AssertDynamic(o, o2);
// Update it
o2.title = "New Title";
db.Save("petapoco", "id", o2);
// Retrieve itagain
var o3 = db.Single<dynamic>("SELECT * FROM petapoco WHERE id=@0", o.id);
// Check it
AssertDynamic(o2, o3);
// Delete it
db.Delete("petapoco", "id", o3);
// Should be gone!
var o4 = db.SingleOrDefault<dynamic>("SELECT * FROM petapoco WHERE id=@0", o.id);
Assert.IsNull(o4);
}
[Test]
public void Manual_PrimaryKey()
{
var o=new petapoco2();
o.email="blah@blah.com";
o.name="Mr Blah";
db.Insert(o);
var o2 = db.SingleOrDefault<petapoco2>("WHERE email=@0", "blah@blah.com");
Assert.AreEqual(o2.name, "Mr Blah");
}
[Test]
public void SingleValueRequest()
{
var id = InsertRecords(1);
var id2 = db.SingleOrDefault<long>("SELECT id from petapoco WHERE id=@0", id);
Assert.AreEqual(id, id2);
}
[Test]
public void Exists_Query_Does()
{
var id = InsertRecords(10);
Assert.IsTrue(db.Exists<deco>("id = @0", id));
Assert.IsTrue(db.Exists<deco>(id));
}
[Test]
public void Exists_Query_DoesNot()
{
var id = InsertRecords(10);
Assert.IsFalse(db.Exists<deco>("id = @0", id+100));
Assert.IsFalse(db.Exists<deco>(id + 100));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PetaPoco.Tests
{
class Utils
{
public static string LoadTextResource(string name)
{
// get a reference to the current assembly
var a = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.StreamReader r = new System.IO.StreamReader(a.GetManifestResourceStream(name));
string str = r.ReadToEnd();
r.Close();
return str;
}
}
}
DROP TABLE IF EXISTS petapoco;
DROP TABLE IF EXISTS petapoco2;
DROP TABLE IF EXISTS petapoco;
CREATE TABLE petapoco (
id bigint AUTO_INCREMENT NOT NULL,
title varchar(127) NOT NULL,
draft BOOL NOT NULL,
date_created datetime NOT NULL,
date_edited datetime NULL,
content longtext NOT NULL,
state smallint UNSIGNED NOT NULL,
`col w space` int,
nullreal float NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
DROP TABLE IF EXISTS petapoco2;
CREATE TABLE petapoco2 (
email varchar(127) NOT NULL,
name varchar(127) NOT NULL,
PRIMARY KEY (email)
) ENGINE=INNODB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaPoco;
namespace PetaPoco.Tests
{
enum State
{
Yes,
No,
Maybe,
}
// Non-decorated true poco
class poco
{
public long id { get; set; }
public string title { get; set; }
public bool draft { get; set; }
public DateTime date_created { get; set; }
public DateTime? date_edited { get; set; }
public string content { get; set; }
public State state { get; set; }
[Column("col w space")] public int col_w_space { get; set; }
public float? nullreal { get; set; }
}
// Attributed not-so-true poco
[TableName("petapoco")]
[PrimaryKey("id", SequenceName="article_id_seq")]
[ExplicitColumns]
class deco
{
[Column] public long id { get; set; }
[Column] public string title { get; set; }
[Column] public bool draft { get; set; }
[Column(ForceToUtc=true)] public DateTime date_created { get; set; }
[Column(ForceToUtc = true)] public DateTime? date_edited { get; set; }
[Column] public string content { get; set; }
[Column] public State state { get; set; }
[Column("col w space")] public int col_w_space { get; set; }
[Column] public float? nullreal { get; set; }
}
// Attributed not-so-true poco
[TableName("petapoco")]
[PrimaryKey("id")]
[ExplicitColumns]
class deco_explicit
{
[Column]public long id { get; set; }
[Column]public string title { get; set; }
[Column]public bool draft { get; set; }
[Column]public DateTime date_created { get; set; }
[Column]public State state { get; set; }
public string content { get; set; }
[Column("col w space")]public int col_w_space { get; set; }
[Column] public float? nullreal { get; set; }
}
// Attributed not-so-true poco
[TableName("petapoco")]
[PrimaryKey("id")]
class deco_non_explicit
{
public long id { get; set; }
public string title { get; set; }
public bool draft { get; set; }
public DateTime date_created { get; set; }
public State state { get; set; }
[Ignore] public string content { get; set; }
[Column("col w space")] public int col_w_space { get; set; }
public float? nullreal { get; set; }
}
[TableName("petapoco2")]
[PrimaryKey("email", AutoIncrement=false)]
class petapoco2
{
public string email { get; set; }
public string name { get; set; }
}
}
DROP TABLE IF EXISTS petapoco;
DROP TABLE IF EXISTS petapoco2;

DROP TABLE IF EXISTS petapoco;
CREATE TABLE petapoco (
id bigserial NOT NULL,
title varchar(127) NOT NULL,
draft boolean NOT NULL,
date_created timestamp NOT NULL,
date_edited timestamp NULL,
content text NOT NULL,
state int NOT NULL,
"col w space" int,
nullreal real NULL,
PRIMARY KEY (id)
);
DROP TABLE IF EXISTS petapoco2;
CREATE TABLE petapoco2 (
email varchar(127) NOT NULL,
name varchar(127) NOT NULL,
PRIMARY KEY (email)
);
IF OBJECT_ID('dbo.petapoco','U') IS NOT NULL
DROP TABLE dbo.petapoco;
IF OBJECT_ID('dbo.petapoco2','U') IS NOT NULL
DROP TABLE dbo.petapoco2;
IF OBJECT_ID('dbo.petapoco','U') IS NOT NULL
DROP TABLE dbo.petapoco;
CREATE TABLE petapoco (
id bigint IDENTITY(1,1) NOT NULL,
title varchar(127) NOT NULL,
draft bit NOT NULL,
date_created datetime NOT NULL,
date_edited datetime NULL,
content VARCHAR(MAX) NOT NULL,
state int NOT NULL,
[col w space] int,
nullreal real NULL,
PRIMARY KEY (id)
);
IF OBJECT_ID('dbo.petapoco2','U') IS NOT NULL
DROP TABLE dbo.petapoco2;
CREATE TABLE petapoco2 (
email varchar(127) NOT NULL,
name varchar(127) NOT NULL,
PRIMARY KEY (email)
);
DELETE FROM petapoco;
\ No newline at end of file
DELETE FROM petapoco;
\ No newline at end of file
docker-compose stop
\ No newline at end of file
docker-compose up
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9B2D7B13-A47D-497C-9E46-85B78C2D074E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PetaPoco.Tests.Integration.SingleFile</RootNamespace>
<AssemblyName>PetaPoco.Tests.Integration.SingleFile</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<LangVersion>5</LangVersion>
</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>
<CodeAnalysisRuleSet>PetaPoco.Tests.Integration.SingleFile.ruleset</CodeAnalysisRuleSet>
</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>
<CodeAnalysisRuleSet>PetaPoco.Tests.Integration.SingleFile.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Output\PetaPoco.cs">
<Link>PetaPoco.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<None Include="PetaPoco.Tests.Integration.SingleFile.ruleset" />
</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>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for PetaPoco.Tests.Integration.SingleFile" Description="Code analysis rules for PetaPoco.Tests.Integration.SingleFile.csproj." ToolsVersion="14.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />
<Rule Id="CA1400" Action="Warning" />
<Rule Id="CA1401" Action="Warning" />
<Rule Id="CA1403" Action="Warning" />
<Rule Id="CA1404" Action="Warning" />
<Rule Id="CA1405" Action="Warning" />
<Rule Id="CA1410" Action="Warning" />
<Rule Id="CA1415" Action="Warning" />
<Rule Id="CA1821" Action="Warning" />
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA1901" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2101" Action="Warning" />
<Rule Id="CA2108" Action="Warning" />
<Rule Id="CA2111" Action="Warning" />
<Rule Id="CA2112" Action="Warning" />
<Rule Id="CA2114" Action="Warning" />
<Rule Id="CA2116" Action="Warning" />
<Rule Id="CA2117" Action="Warning" />
<Rule Id="CA2122" Action="Warning" />
<Rule Id="CA2123" Action="Warning" />
<Rule Id="CA2124" Action="Warning" />
<Rule Id="CA2126" Action="Warning" />
<Rule Id="CA2131" Action="Warning" />
<Rule Id="CA2132" Action="Warning" />
<Rule Id="CA2133" Action="Warning" />
<Rule Id="CA2134" Action="Warning" />
<Rule Id="CA2137" Action="Warning" />
<Rule Id="CA2138" Action="Warning" />
<Rule Id="CA2140" Action="Warning" />
<Rule Id="CA2141" Action="Warning" />
<Rule Id="CA2146" Action="Warning" />
<Rule Id="CA2147" Action="Warning" />
<Rule Id="CA2149" Action="Warning" />
<Rule Id="CA2200" Action="Warning" />
<Rule Id="CA2202" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2220" Action="Warning" />
<Rule Id="CA2229" Action="Warning" />
<Rule Id="CA2231" Action="Warning" />
<Rule Id="CA2232" Action="Warning" />
<Rule Id="CA2235" Action="Warning" />
<Rule Id="CA2236" Action="Warning" />
<Rule Id="CA2237" Action="Warning" />
<Rule Id="CA2238" Action="Warning" />
<Rule Id="CA2240" Action="Warning" />
<Rule Id="CA2241" Action="Warning" />
<Rule Id="CA2242" Action="Warning" />
</Rules>
<Rules AnalyzerId="RefactoringEssentials" RuleNamespace="RefactoringEssentials">
<Rule Id="RECS0145" Action="None" />
</Rules>
</RuleSet>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
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("PetaPoco.Tests.Integration.SingleFile")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PetaPoco.Tests.Integration.SingleFile")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[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("9b2d7b13-a47d-497c-9e46-85b78c2d074e")]
// 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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessUpdateTests : BaseUpdateTests
{
public MsAccessUpdateTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9AAEF733-6F2A-4297-A0E2-D065212940A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PetaPoco.Tests.Integration.x86</RootNamespace>
<AssemblyName>PetaPoco.Tests.Integration.x86</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>
<CodeAnalysisRuleSet>PetaPoco.Tests.Integration.x86.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
</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>
<CodeAnalysisRuleSet>PetaPoco.Tests.Integration.x86.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Shouldly, Version=2.6.0.0, Culture=neutral, PublicKeyToken=6042cbcb05cbc941, processorArchitecture=MSIL">
<HintPath>..\packages\Shouldly.2.6.0\lib\net40\Shouldly.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseDatabase.cs">
<Link>Databases\BaseDatabase.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseDatabaseTests.cs">
<Link>Databases\BaseDatabaseTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseDeleteTests.cs">
<Link>Databases\BaseDeleteTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseExecuteTests.cs">
<Link>Databases\BaseExecuteTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseInsertTests.cs">
<Link>Databases\BaseInsertTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseQueryLinqTests.cs">
<Link>Databases\BaseQueryLinqTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseQueryTests.cs">
<Link>Databases\BaseQueryTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\BaseUpdateTests.cs">
<Link>Databases\BaseUpdateTests.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Databases\DBTestProvider.cs">
<Link>Databases\DBTestProvider.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\Note.cs">
<Link>Models\Note.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\NoteNullablePrimary.cs">
<Link>Models\NoteNullablePrimary.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\Order.cs">
<Link>Models\Order.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\OrderLine.cs">
<Link>Models\OrderLine.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\OrderLineStatus.cs">
<Link>Models\OrderLineStatus.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\OrderStatus.cs">
<Link>Models\OrderStatus.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\Person.cs">
<Link>Models\Person.cs</Link>
</Compile>
<Compile Include="..\PetaPoco.Tests.Integration\Models\TransactionLog.cs">
<Link>Models\TransactionLog.cs</Link>
</Compile>
<Compile Include="Databases\MSAccess\MsAccessDatabaseTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessDBTestProvider.cs" />
<Compile Include="Databases\MSAccess\MsAccessDeleteTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessExecuteTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessInsertTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessQueryLinqTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessQueryTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessUpdateTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="PetaPoco.Tests.Integration.x86.ruleset">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Databases\MSAccess\petapoco.accdb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="Scripts\MSAccessBuildDatabase.sql">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PetaPoco\PetaPoco.csproj">
<Project>{33699753-151d-4100-8f12-9ae1aeb5c5bd}</Project>
<Name>PetaPoco</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</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>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for PetaPoco.Tests.Integration.x86" Description="Code analysis rules for PetaPoco.Tests.Integration.x86.csproj." ToolsVersion="14.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />
<Rule Id="CA1400" Action="Warning" />
<Rule Id="CA1401" Action="Warning" />
<Rule Id="CA1403" Action="Warning" />
<Rule Id="CA1404" Action="Warning" />
<Rule Id="CA1405" Action="Warning" />
<Rule Id="CA1410" Action="Warning" />
<Rule Id="CA1415" Action="Warning" />
<Rule Id="CA1821" Action="Warning" />
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA1901" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2101" Action="Warning" />
<Rule Id="CA2108" Action="Warning" />
<Rule Id="CA2111" Action="Warning" />
<Rule Id="CA2112" Action="Warning" />
<Rule Id="CA2114" Action="Warning" />
<Rule Id="CA2116" Action="Warning" />
<Rule Id="CA2117" Action="Warning" />
<Rule Id="CA2122" Action="Warning" />
<Rule Id="CA2123" Action="Warning" />
<Rule Id="CA2124" Action="Warning" />
<Rule Id="CA2126" Action="Warning" />
<Rule Id="CA2131" Action="Warning" />
<Rule Id="CA2132" Action="Warning" />
<Rule Id="CA2133" Action="Warning" />
<Rule Id="CA2134" Action="Warning" />
<Rule Id="CA2137" Action="Warning" />
<Rule Id="CA2138" Action="Warning" />
<Rule Id="CA2140" Action="Warning" />
<Rule Id="CA2141" Action="Warning" />
<Rule Id="CA2146" Action="Warning" />
<Rule Id="CA2147" Action="Warning" />
<Rule Id="CA2149" Action="Warning" />
<Rule Id="CA2200" Action="Warning" />
<Rule Id="CA2202" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2220" Action="Warning" />
<Rule Id="CA2229" Action="Warning" />
<Rule Id="CA2231" Action="Warning" />
<Rule Id="CA2232" Action="Warning" />
<Rule Id="CA2235" Action="Warning" />
<Rule Id="CA2236" Action="Warning" />
<Rule Id="CA2237" Action="Warning" />
<Rule Id="CA2238" Action="Warning" />
<Rule Id="CA2240" Action="Warning" />
<Rule Id="CA2241" Action="Warning" />
<Rule Id="CA2242" Action="Warning" />
</Rules>
<Rules AnalyzerId="RefactoringEssentials" RuleNamespace="RefactoringEssentials">
<Rule Id="RECS0145" Action="None" />
</Rules>
</RuleSet>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
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("PetaPoco.Tests.Integration.x86")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PetaPoco.Tests.Integration.x86")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("9aaef733-6f2a-4297-a0e2-d065212940a3")]
// 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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<clear />
<add name="msaccess" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|Databases\MSAccess\petapoco.accdb" providerName="OleDb"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1510.2205" targetFramework="net461" />
<package id="Shouldly" version="2.6.0" targetFramework="net461" />
<package id="xunit" version="2.1.0" targetFramework="net461" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net461" />
<package id="xunit.assert" version="2.1.0" targetFramework="net461" />
<package id="xunit.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net461" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net461" />
</packages>
\ No newline at end of file
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2018/07/02</date>
#if NETCOREAPP
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
namespace PetaPoco.Tests.Integration
{
public class AppSetting
{
public List<ConnectionStringSetting> ConnectionStrings { get; set; } = new List<ConnectionStringSetting>();
public static AppSetting Load()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
var config = builder.Build();
var app = new AppSetting();
config.GetSection("App").Bind(app);
return app;
}
public class ConnectionStringSetting
{
public string Name { get; set; }
public string ConnectionString { get; set; }
public string ProviderName { get; set; }
}
}
}
#endif
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using System;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/06</date>
// <date>2018/07/02</date>
using System;
using System.Configuration;
......@@ -84,6 +84,7 @@ namespace PetaPoco.Tests.Integration.Databases
}
}
#if !NETCOREAPP
[Fact]
public void Construct_GivenConnectionStringName_ShouldBeValid()
{
......@@ -99,6 +100,7 @@ namespace PetaPoco.Tests.Integration.Databases
_note.ShouldBe(otherNote);
}
}
#endif
[Fact]
public void Construct_GivenConnectionStringAndProvider_ShouldBeValid()
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/06</date>
// <date>2018/07/02</date>
using System;
using PetaPoco.Tests.Integration.Models;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/05</date>
// <date>2018/07/02</date>
using System;
using PetaPoco.Core;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/02/16</date>
// <date>2018/07/02</date>
using System;
using PetaPoco.Tests.Integration.Models;
......@@ -107,7 +107,8 @@ namespace PetaPoco.Tests.Integration.Databases
DB.Single<Person>($"SELECT * FROM {DB.Provider.EscapeTableName("SpecificPeople")} WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0",
_person.Id);
var orderOther =
DB.Single<Order>($"SELECT * FROM {DB.Provider.EscapeTableName("SpecificOrders")} WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0", _order.Id);
DB.Single<Order>($"SELECT * FROM {DB.Provider.EscapeTableName("SpecificOrders")} WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0",
_order.Id);
var orderLineOther =
DB.Single<OrderLine>($"SELECT * FROM {DB.Provider.EscapeTableName("SpecificOrderLines")} WHERE {DB.Provider.EscapeSqlIdentifier("Id")} = @0",
_orderLine.Id);
......@@ -206,7 +207,7 @@ namespace PetaPoco.Tests.Integration.Databases
var id = DB.Insert("Note", "Id", note);
var otherNote = DB.Single<Note>(id);
otherNote.Text.ShouldBe(note.Text);
otherNote.CreatedOn.ShouldBe(note.CreatedOn);
}
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/20</date>
// <date>2018/07/02</date>
using System;
using PetaPoco.Tests.Integration.Models;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/02/04</date>
// <date>2018/07/02</date>
using System;
using System.Collections.Generic;
......@@ -139,7 +139,7 @@ namespace PetaPoco.Tests.Integration.Databases
sql = sql.Replace("@NullableProperty", "CAST(@NullableProperty AS NTEXT)");
}
var results = DB.Query<Order>(sql, new { Status = OrderStatus.Pending, NullableProperty = (string)null }).ToList();
var results = DB.Query<Order>(sql, new { Status = OrderStatus.Pending, NullableProperty = (string) null }).ToList();
results.Count.ShouldBe(3);
results.ForEach(o =>
......@@ -253,7 +253,8 @@ namespace PetaPoco.Tests.Integration.Databases
{
AddOrders(12);
var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper);
var sql =$"WHERE {DB.Provider.EscapeSqlIdentifier(pd.Columns.Values.First(c => c.PropertyInfo.Name == "Status").ColumnName)} = @Status AND @NullableProperty IS NULL";
var sql =
$"WHERE {DB.Provider.EscapeSqlIdentifier(pd.Columns.Values.First(c => c.PropertyInfo.Name == "Status").ColumnName)} = @Status AND @NullableProperty IS NULL";
if (DB.Provider.GetType() == typeof(PostgreSQLDatabaseProvider))
{
......@@ -264,7 +265,7 @@ namespace PetaPoco.Tests.Integration.Databases
sql = sql.Replace("@NullableProperty", "CAST(@NullableProperty AS NTEXT)");
}
var results = DB.Fetch<Order>(sql, new { Status = OrderStatus.Pending, NullableProperty = (string)null });
var results = DB.Fetch<Order>(sql, new { Status = OrderStatus.Pending, NullableProperty = (string) null });
results.Count.ShouldBe(3);
results.ForEach(o =>
......@@ -362,6 +363,7 @@ namespace PetaPoco.Tests.Integration.Databases
Dob = new DateTime(1980 - (18 + 1), 1, 1, 1, 1, 1, DateTimeKind.Utc),
});
}
if (sallysToAdd > i)
{
DB.Insert(new Person
......
......@@ -2,12 +2,11 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using System;
using System.Linq;
using PetaPoco.Core;
using PetaPoco.Internal;
using PetaPoco.Tests.Integration.Models;
using Shouldly;
using Xunit;
......
......@@ -2,11 +2,14 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using System;
using System.IO;
using System.Text;
#if NETCOREAPP
using System.Linq;
#endif
namespace PetaPoco.Tests.Integration.Databases
{
......@@ -23,13 +26,14 @@ namespace PetaPoco.Tests.Integration.Databases
public virtual IDatabase Execute()
{
var db = Database;
using (var s = this.GetType().Assembly.GetManifestResourceStream(ScriptResourceName))
using (var s = GetType().Assembly.GetManifestResourceStream(ScriptResourceName))
{
using (var r = new StreamReader(s, Encoding.UTF8))
{
ExecuteBuildScript(db, r.ReadToEnd());
}
}
return db;
}
......@@ -37,5 +41,23 @@ namespace PetaPoco.Tests.Integration.Databases
{
database.Execute(script);
}
protected virtual IDatabaseBuildConfiguration BuildFromConnectionName(string name)
{
#if NETCOREAPP
var appSettings = AppSetting.Load();
return DatabaseConfiguration.Build()
.UsingConnectionString(appSettings.ConnectionStrings.First(c => c.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).ConnectionString)
.UsingProviderName(appSettings.ConnectionStrings.First(c => c.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).ProviderName);
#else
return DatabaseConfiguration.Build().UsingConnectionStringName(name);
#endif
}
protected virtual IDatabase LoadFromConnectionName(string name)
{
return BuildFromConnectionName(name).Create();
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using System.IO;
using System.Text;
......@@ -13,7 +13,7 @@ namespace PetaPoco.Tests.Integration.Databases.Firebird
{
public class FirebirdDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("firebird").Create();
protected override IDatabase Database => LoadFromConnectionName("Firebird");
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.FirebirdDbBuildDatabase.sql";
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/31</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,19 +2,18 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using System;
using System.Linq;
using PetaPoco.Tests.Integration.Databases;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
public class MsAccessDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("msaccess").Create();
protected override IDatabase Database => LoadFromConnectionName("msaccess");
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.x86.Scripts.MSAccessBuildDatabase.sql";
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSAccessBuildDatabase.sql";
public override void ExecuteBuildScript(IDatabase database, string script)
{
......@@ -32,9 +31,10 @@ namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
catch
{
}
return;
}
base.ExecuteBuildScript(database, s);
});
}
......
......@@ -2,12 +2,11 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessDatabaseTests : BaseDatabaseTests
......
......@@ -2,12 +2,11 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessDeleteTests : BaseDeleteTests
......
......@@ -2,12 +2,11 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessExecuteTests : BaseExecuteTests
......
......@@ -2,12 +2,11 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessInsertTests : BaseInsertTests
......
......@@ -2,12 +2,11 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessQueryLinqTests : BaseQueryLinqTests
......
......@@ -2,14 +2,13 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
// <date>2018/07/02</date>
using System;
using PetaPoco.Tests.Integration.Databases;
using Shouldly;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessQueryTests : BaseQueryTests
......
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2018/07/02</date>
using Xunit;
namespace PetaPoco.Tests.Integration.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessUpdateTests : BaseUpdateTests
{
public MsAccessUpdateTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
\ No newline at end of file
......@@ -2,14 +2,32 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using System;
using System.Linq;
namespace PetaPoco.Tests.Integration.Databases.MSSQL
{
public class MssqlDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("mssql").Create();
private string _connectionName = "mssql";
protected override IDatabase Database => LoadFromConnectionName(_connectionName);
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSSQLBuildDatabase.sql";
public override IDatabase Execute()
{
_connectionName = "mssql_builder";
base.Execute();
_connectionName = "mssql";
return Database;
}
public override void ExecuteBuildScript(IDatabase database, string script)
{
script.Split(new[] { "GO" }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(s => { base.ExecuteBuildScript(database, s); });
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/14</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/20</date>
// <date>2018/07/02</date>
using System;
using Shouldly;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/02/06</date>
// <date>2018/07/02</date>
using System;
using System.Collections.Generic;
......@@ -21,7 +21,7 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
: base(new MssqlDBTestProvider())
{
}
[Fact]
public void Query_ForPocoGivenDbColumPocoOverlapSqlStringAndParameters_ShouldReturnValidPocoCollection()
{
......@@ -44,28 +44,6 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
poco2.Column2.ShouldBe("A");
}
[ExplicitColumns]
[TableName("BugInvestigation_64O6LT8U")]
public class PocoOverlapPoco1
{
[Column("ColumnA")]
public string Column1 { get; set; }
[Column]
public string Column2 { get; set; }
}
[ExplicitColumns]
[TableName("BugInvestigation_5TN5C4U4")]
public class PocoOverlapPoco2
{
[Column("ColumnA")]
public string Column1 { get; set; }
[Column]
public string Column2 { get; set; }
}
[Fact]
public void Page_ForPocoGivenSqlStringWithEscapedOrderByColumn_ShouldReturnValidPocoCollection()
{
......@@ -151,7 +129,7 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
o.CreatedBy.ShouldStartWith("Harry");
});
}
[Fact]
public void Query_MultiResultsSet_SingleResultsSetSinglePoco__ShouldReturnValidPocoCollection()
{
......@@ -187,7 +165,11 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
List<Order> result;
using (var multi = DB.QueryMultiple(sql, "Peta0"))
{
result = multi.Read<Order, Person, Order>((o, p) => { o.Person = p; return o; }).ToList();
result = multi.Read<Order, Person, Order>((o, p) =>
{
o.Person = p;
return o;
}).ToList();
}
result.Count.ShouldBe(1);
......@@ -212,7 +194,8 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
var pd = PocoData.ForType(typeof(Person), DB.DefaultMapper);
var od = PocoData.ForType(typeof(Order), DB.DefaultMapper);
var sql = $"SET CONCAT_NULL_YIELDS_NULL ON;SELECT * FROM [{od.TableInfo.TableName}] o WHERE [{od.Columns.Values.First(c => c.PropertyInfo.Name == "Id").ColumnName}] = @0;SELECT * FROM [{pd.TableInfo.TableName}] p WHERE [{pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName}] = @1;";
var sql =
$"SET CONCAT_NULL_YIELDS_NULL ON;SELECT * FROM [{od.TableInfo.TableName}] o WHERE [{od.Columns.Values.First(c => c.PropertyInfo.Name == "Id").ColumnName}] = @0;SELECT * FROM [{pd.TableInfo.TableName}] p WHERE [{pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName}] = @1;";
Order order;
using (var multi = DB.QueryMultiple(sql, "1", "Peta0"))
......@@ -247,7 +230,11 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
List<Order> results;
using (var multi = DB.QueryMultiple(sql))
{
results = multi.Read<Order, Person, Order>((o, p) => { o.Person = p; return o; }).ToList();
results = multi.Read<Order, Person, Order>((o, p) =>
{
o.Person = p;
return o;
}).ToList();
var orderLines = multi.Read<OrderLine>().ToList();
foreach (var order in results)
......@@ -280,5 +267,27 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQL
secondOrderLine.SellPrice.ShouldBe(19.98m);
});
}
[ExplicitColumns]
[TableName("BugInvestigation_64O6LT8U")]
public class PocoOverlapPoco1
{
[Column("ColumnA")]
public string Column1 { get; set; }
[Column]
public string Column2 { get; set; }
}
[ExplicitColumns]
[TableName("BugInvestigation_5TN5C4U4")]
public class PocoOverlapPoco2
{
[Column("ColumnA")]
public string Column1 { get; set; }
[Column]
public string Column2 { get; set; }
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/14</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using System;
using System.Configuration;
......@@ -14,20 +14,37 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQLCe
{
public class MssqlCeDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("mssqlce").Create();
protected override IDatabase Database => LoadFromConnectionName("mssqlce");
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSSQLCeBuildDatabase.sql";
public MssqlCeDBTestProvider()
{
// Hack: Nuget package is old and dones't support newer content
// ReSharper disable AssignNullToNotNullAttribute
var codeBase = typeof(SqlCeConnection).Assembly.CodeBase;
var uri = new UriBuilder(codeBase);
var dllPath = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path));
var nativeBinaryPath = Path.GetFullPath(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
$".nuget\\packages\\microsoft.sqlserver.compact\\4.0.8876.1\\NativeBinaries\\{(Environment.Is64BitProcess ? "amd64" : "x86")}"));
Directory.GetFiles(nativeBinaryPath, "*", SearchOption.AllDirectories).ToList()
.ForEach(f =>
{
var destFilePath = Path.Combine(dllPath, Path.GetFileName(f));
if (!File.Exists(destFilePath))
File.Copy(f, destFilePath);
});
// ReSharper restore AssignNullToNotNullAttribute
}
public override IDatabase Execute()
{
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "petapoco.sdf")))
{
using (var engine = new SqlCeEngine(ConfigurationManager.ConnectionStrings["mssqlce"].ConnectionString))
{
engine.CreateDatabase();
}
//File.Delete(Path.Combine(Environment.CurrentDirectory, "petapoco.sdf"));
}
return base.Execute();
}
......@@ -48,6 +65,7 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQLCe
catch
{
}
return;
}
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/14</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/20</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/28</date>
// <date>2018/07/02</date>
using System;
using Shouldly;
......@@ -18,20 +18,19 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQLCe
{
}
[Fact]
public virtual void Query_ForEnumWithUnderlyingType_ShouldConvertValues()
{
foreach (var sqltype in new[] { "TINYINT", "SMALLINT", "INTEGER", "BIGINT" })
{
var t1 = DB.Single<T1>($"SELECT CONVERT({sqltype}, 1) AS [C]");
t1.C.ShouldBe((E1)1);
t1.C.ShouldBe((E1) 1);
var t2 = DB.Single<T2>($"SELECT CONVERT({sqltype}, 1) AS [C]");
t2.C.ShouldBe((E2)1);
t2.C.ShouldBe((E2) 1);
var t3 = DB.Single<T3>($"SELECT CONVERT({sqltype}, 1) AS [C]");
t3.C.ShouldBe((E3)1);
t3.C.ShouldBe((E3) 1);
var t4 = DB.Single<T4>($"SELECT CONVERT({sqltype}, 1) AS [C]");
t4.C.ShouldBe((E4)1);
t4.C.ShouldBe((E4) 1);
}
}
......@@ -45,7 +44,7 @@ namespace PetaPoco.Tests.Integration.Databases.MSSQLCe
// INTEGER => enum?
var t2 = DB.Single<TestClass>("SELECT 1 AS [EnumValue]");
t2.EnumValue.HasValue.ShouldBeTrue();
t2.EnumValue.Value.ShouldBe((E3)1);
t2.EnumValue.Value.ShouldBe((E3) 1);
// TEXT => enum?
var t3 = DB.Single<TestClass>("SELECT 'Hello' AS [EnumValue]");
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,13 +2,13 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
namespace PetaPoco.Tests.Integration.Databases.MariaDb
{
public class MariaDbDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("MariaDb").Create();
protected override IDatabase Database => LoadFromConnectionName("MariaDb");
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MariaDbBuildDatabase.sql";
}
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/20</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/28</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,13 +2,13 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
namespace PetaPoco.Tests.Integration.Databases.MySQL
{
public class MySqlDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("mysql").Create();
protected override IDatabase Database => LoadFromConnectionName("MySQL");
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MySqlBuildDatabase.sql";
}
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/14</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2015/12/13</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/03/07</date>
// <date>2018/07/02</date>
using Shouldly;
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/11</date>
// <date>2018/07/02</date>
using Xunit;
......
......@@ -2,7 +2,7 @@
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/28</date>
// <date>2018/07/02</date>
using Xunit;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册