Skip to content

Commit

Permalink
Switched to PetaTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Robinson committed Jul 31, 2011
1 parent a645099 commit e0a863f
Show file tree
Hide file tree
Showing 16 changed files with 2,999 additions and 307 deletions.
25 changes: 25 additions & 0 deletions Performance1.psess
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<VSPerformanceSession Version="1.00">
<Options>
<CollectionMethod>Sampling</CollectionMethod>
<AllocationMethod>None</AllocationMethod>
<AddReport>true</AddReport>
<UniqueReport>Timestamp</UniqueReport>
<SamplingMethod>Cycles</SamplingMethod>
<CycleCount>10000000</CycleCount>
<PageFaultCount>10</PageFaultCount>
<SysCallCount>10</SysCallCount>
<SamplingCounter PlatformID="00000000" CounterID="0000000000000000" ReloadValue="000000000000000a" />
<RelocateBinaries>false</RelocateBinaries>
<CollectOnHpcCluster>false</CollectOnHpcCluster>
<HPCSettings>
<TargetSelection>UnknownDisabled</TargetSelection>
</HPCSettings>
<HardwareCounters EnableHWCounters="false" />
</Options>
<PreinstrumentEvent>
<InstrEventExclude>false</InstrEventExclude>
</PreinstrumentEvent>
<PostinstrumentEvent>
<InstrEventExclude>false</InstrEventExclude>
</PostinstrumentEvent>
</VSPerformanceSession>
18 changes: 9 additions & 9 deletions PetaPoco.Tests/ColumnMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using PetaTest;

namespace PetaPoco.Tests
{
Expand Down Expand Up @@ -67,7 +67,7 @@ public Func<object, object> GetToDbConverter(Type SourceType)
}

[TestFixture]
public class ColumnMapper : AssertionHelper
public class ColumnMapper
{


Expand All @@ -78,13 +78,13 @@ public void NoColumnMapper()
PetaPoco.Database.Mapper = new MyColumnMapper();
var pd=PetaPoco.Database.PocoData.ForType(typeof(Poco2));

Expect(pd.Columns.Count, Is.EqualTo(3));
Expect(pd.Columns["prop1"].PropertyInfo.Name, Is.EqualTo("prop1"));
Expect(pd.Columns["remapped2"].ColumnName, Is.EqualTo("remapped2"));
Expect(pd.Columns["prop3"].ColumnName, Is.EqualTo("prop3"));
Expect(string.Join(", ", pd.QueryColumns), Is.EqualTo("prop1, remapped2"));
Expect(pd.TableInfo.PrimaryKey, Is.EqualTo("id"));
Expect(pd.TableInfo.TableName, Is.EqualTo("petapoco"));
Assert.AreEqual(pd.Columns.Count, 3);
Assert.AreEqual(pd.Columns["prop1"].PropertyInfo.Name, "prop1");
Assert.AreEqual(pd.Columns["remapped2"].ColumnName, "remapped2");
Assert.AreEqual(pd.Columns["prop3"].ColumnName, "prop3");
Assert.AreEqual(string.Join(", ", pd.QueryColumns), "prop1, remapped2");
Assert.AreEqual(pd.TableInfo.PrimaryKey, "id");
Assert.AreEqual(pd.TableInfo.TableName, "petapoco");
}
}
}
12 changes: 6 additions & 6 deletions PetaPoco.Tests/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using PetaTest;

namespace PetaPoco.Tests
{
[TestFixture]
class Misc : AssertionHelper
class Misc
{
Database db = new Database("sqlserver");

[Test]
public void EscapeColumnName()
{
Expect(db.EscapeSqlIdentifier("column.name"), Is.EqualTo("[column.name]"));
Expect(db.EscapeSqlIdentifier("column name"), Is.EqualTo("[column name]"));
Assert.AreEqual(db.EscapeSqlIdentifier("column.name"), "[column.name]");
Assert.AreEqual(db.EscapeSqlIdentifier("column name"), "[column name]");
}

[Test]
public void EscapeTableName()
{
Expect(db.EscapeTableName("column.name"), Is.EqualTo("column.name"));
Expect(db.EscapeTableName("column name"), Is.EqualTo("[column name]"));
Assert.AreEqual(db.EscapeTableName("column.name"), "column.name");
Assert.AreEqual(db.EscapeTableName("column name"), "[column name]");
}
}
}
132 changes: 66 additions & 66 deletions PetaPoco.Tests/MultiPocoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using PetaTest;
using PetaPoco;

namespace PetaPoco.Tests
{
public class MultiPocoTests : AssertionHelper
public class MultiPocoTests
{
[TableName("posts")]
[PrimaryKey("id")]
Expand Down Expand Up @@ -104,20 +104,20 @@ public void DeleteDB()
public void Basic()
{
var posts = db.Fetch<post, author>("SELECT * FROM posts LEFT JOIN authors ON posts.author = authors.id ORDER BY posts.id");
Expect(posts.Count, Is.EqualTo(3));

Expect(posts[0].id, Is.EqualTo(1));
Expect(posts[0].title, Is.EqualTo("post1"));
Expect(posts[0].author, Is.EqualTo(1));
Expect(posts[0].author_obj.name, Is.EqualTo("Bill"));
Expect(posts[1].id, Is.EqualTo(2));
Expect(posts[1].title, Is.EqualTo("post2"));
Expect(posts[1].author, Is.EqualTo(1));
Expect(posts[1].author_obj.name, Is.EqualTo("Bill"));
Expect(posts[2].id, Is.EqualTo(3));
Expect(posts[2].title, Is.EqualTo("post3"));
Expect(posts[2].author, Is.EqualTo(2));
Expect(posts[2].author_obj.name, Is.EqualTo("Ted"));
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]
Expand All @@ -131,20 +131,20 @@ public void CustomRelator()
},
"SELECT * FROM posts LEFT JOIN authors ON posts.author = authors.id ORDER BY posts.id");

Expect(posts.Count, Is.EqualTo(3));
Expect(posts[0].author_obj, Is.Not.SameAs(posts[1].author_obj));
Expect(posts[0].id, Is.EqualTo(1));
Expect(posts[0].title, Is.EqualTo("post1"));
Expect(posts[0].author, Is.EqualTo(1));
Expect(posts[0].author_obj.name, Is.EqualTo("Bill"));
Expect(posts[1].id, Is.EqualTo(2));
Expect(posts[1].title, Is.EqualTo("post2"));
Expect(posts[1].author, Is.EqualTo(1));
Expect(posts[1].author_obj.name, Is.EqualTo("Bill"));
Expect(posts[2].id, Is.EqualTo(3));
Expect(posts[2].title, Is.EqualTo("post3"));
Expect(posts[2].author, Is.EqualTo(2));
Expect(posts[2].author_obj.name, Is.EqualTo("Ted"));
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
Expand Down Expand Up @@ -180,23 +180,23 @@ public void ManyToOne()
);


Expect(posts.Count, Is.EqualTo(3));
Expect(posts[0].author_obj, Is.SameAs(posts[1].author_obj));
Assert.AreEqual(posts.Count, 3);
Assert.AreSame(posts[0].author_obj, posts[1].author_obj);

Expect(posts[0].id, Is.EqualTo(1));
Expect(posts[0].title, Is.EqualTo("post1"));
Expect(posts[0].author, Is.EqualTo(1));
Expect(posts[0].author_obj.name, Is.EqualTo("Bill"));
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");

Expect(posts[1].id, Is.EqualTo(2));
Expect(posts[1].title, Is.EqualTo("post2"));
Expect(posts[1].author, Is.EqualTo(1));
Expect(posts[1].author_obj.name, Is.EqualTo("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");

Expect(posts[2].id, Is.EqualTo(3));
Expect(posts[2].title, Is.EqualTo("post3"));
Expect(posts[2].author, Is.EqualTo(2));
Expect(posts[2].author_obj.name, Is.EqualTo("Ted"));
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
Expand Down Expand Up @@ -259,14 +259,14 @@ public void OneToMany()
"SELECT * FROM authors LEFT JOIN posts ON posts.author = authors.id ORDER BY posts.id"
);

Expect(authors.Count, Is.EqualTo(2));
Expect(authors[0].name, Is.EqualTo("Bill"));
Expect(authors[0].posts.Count, Is.EqualTo(2));
Expect(authors[0].posts[0].title, Is.EqualTo("post1"));
Expect(authors[0].posts[1].title, Is.EqualTo("post2"));
Expect(authors[1].name, Is.EqualTo("Ted"));
Expect(authors[1].posts.Count, Is.EqualTo(1));
Expect(authors[1].posts[0].title, Is.EqualTo("post3"));
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]
Expand All @@ -292,20 +292,20 @@ public void ManyToOne_Lambda()
);


Expect(posts.Count, Is.EqualTo(3));
Expect(posts[0].author_obj, Is.SameAs(posts[1].author_obj));
Expect(posts[0].id, Is.EqualTo(1));
Expect(posts[0].title, Is.EqualTo("post1"));
Expect(posts[0].author, Is.EqualTo(1));
Expect(posts[0].author_obj.name, Is.EqualTo("Bill"));
Expect(posts[1].id, Is.EqualTo(2));
Expect(posts[1].title, Is.EqualTo("post2"));
Expect(posts[1].author, Is.EqualTo(1));
Expect(posts[1].author_obj.name, Is.EqualTo("Bill"));
Expect(posts[2].id, Is.EqualTo(3));
Expect(posts[2].title, Is.EqualTo("post3"));
Expect(posts[2].author, Is.EqualTo(2));
Expect(posts[2].author_obj.name, Is.EqualTo("Ted"));
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");
}


Expand Down
9 changes: 7 additions & 2 deletions PetaPoco.Tests/PetaPoco.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E6787C52-7549-44CD-AA6E-AB9D55946AB9}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PetaPoco.Tests</RootNamespace>
<AssemblyName>PetaPoco.Tests</AssemblyName>
Expand Down Expand Up @@ -47,12 +47,14 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>PetaPoco.Tests.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Npgsql">
<HintPath>..\..\..\..\..\..\Program Files\PostgreSQL\.NET Provider\Npgsql.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.6.10205, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
Expand All @@ -68,6 +70,8 @@
<Compile Include="MultiPocoTests.cs" />
<Compile Include="Misc.cs" />
<Compile Include="ColumnMapper.cs" />
<Compile Include="PetaTest.cs" />
<Compile Include="Program.cs" />
<Compile Include="SqlBuilder.cs" />
<Compile Include="poco.cs" />
<Compile Include="Tests.cs" />
Expand All @@ -78,6 +82,7 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="mysql_init.sql" />
Expand Down
7 changes: 4 additions & 3 deletions PetaPoco.Tests/PetaPoco.Tests.csproj.user
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartAction>Program</StartAction>
<StartAction>Project</StartAction>
<StartProgram>C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit.exe</StartProgram>
<StartArguments>PetaPoco.Tests.dll /run</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartAction>Program</StartAction>
<StartAction>Project</StartAction>
<StartProgram>C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit.exe</StartProgram>
<StartArguments>PetaPoco.Tests.dll /run</StartArguments>
<StartArguments>
</StartArguments>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory />
Expand Down
Loading

0 comments on commit e0a863f

Please sign in to comment.