Skip to content

Commit

Permalink
BetterModules: created new project for database integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Audrunas committed Mar 2, 2015
1 parent 75183f3 commit 7d38943
Show file tree
Hide file tree
Showing 28 changed files with 345 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?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>{890E75A2-68E2-4579-91EC-64DEBB51723D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BetterModules.Core.Database.Tests</RootNamespace>
<AssemblyName>BetterModules.Core.Database.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<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>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</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\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac">
<HintPath>..\packages\Autofac.3.1.5\lib\net40\Autofac.dll</HintPath>
</Reference>
<Reference Include="FluentMigrator">
<HintPath>..\packages\FluentMigrator.1.0.6.0\lib\40\FluentMigrator.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate">
<HintPath>..\packages\FluentNHibernate.1.3.0.733\lib\FluentNHibernate.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="NHibernate">
<HintPath>..\packages\NHibernate.3.3.3.4001\lib\Net35\NHibernate.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
</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.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataAccess\DataContext\EventListeners\DeleteEventListenerIntegrationTests.cs" />
<Compile Include="DataAccess\DataContext\EventListeners\SaveOrUpdateEventListenerTests.cs" />
<Compile Include="DataAccess\DataContext\Fetching\DefaultFetchingProviderIntegrationTests.cs" />
<Compile Include="DataAccess\DataContext\Interceptors\StaleInterceptorIntegrationTests.cs" />
<Compile Include="DataAccess\DataContext\QueryableExtensionsIntegrationTests.cs" />
<Compile Include="DataAccess\DataContext\QueryOverExtensionsIntegrationTests.cs" />
<Compile Include="DataAccess\DataContext\RestrictionsExtensionsIntegrationTests.cs" />
<Compile Include="DataAccess\DefaultRepositoryIntegrationTests.cs" />
<Compile Include="DatabaseTestBase.cs" />
<Compile Include="Models\EntityMapBaseIntegrationTests.cs" />
<Compile Include="Models\EntitySubClassMapBaseIntergrationTests.cs" />
<Compile Include="TestHelpers\Migrations\TestDatabaseInitializer.cs" />
<Compile Include="TestHelpers\DatabaseRandomTestDataProvider.cs" />
<Compile Include="TestHelpers\TestDatabaseCreator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Data\BetterModulesTestsDataSet.mdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="App_Data\BetterModulesTestsDataSet_log.ldf">
<DependentUpon>BetterModulesTestsDataSet.mdf</DependentUpon>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<Content Include="Config\connectionStrings.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\modules.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\Temp\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BetterModules.Core.Tests\BetterModules.Core.Tests.csproj">
<Project>{bfe98842-c880-4e23-9898-32acb2e95a2f}</Project>
<Name>BetterModules.Core.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\BetterModules.Core\BetterModules.Core.csproj">
<Project>{c97b2899-5ac5-4528-b205-478d4183676d}</Project>
<Name>BetterModules.Core</Name>
</ProjectReference>
<ProjectReference Include="..\BetterModules.Sample.Module\BetterModules.Sample.Module.csproj">
<Project>{ed95b78c-2448-4096-a89c-a2ca3916783a}</Project>
<Name>BetterModules.Sample.Module</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- 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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>

<connectionStrings>
<add name="BetterModulesTests" connectionString="NO_CONNECTION_STRING" />
</connectionStrings>
8 changes: 8 additions & 0 deletions BetterModules.Core.Database.Tests/Config/modules.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<modulesSettings>
<database
schemaName="dbo"
connectionStringName="BetterModulesTests"
databaseType="MsSql2008" >
</database>
</modulesSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using BetterModules.Core.Security;
using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext.EventListeners
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext.EventListeners
{
[TestFixture]
public class DeleteEventListenerIntegrationTests : DatabaseTestBase
{
[Test]
public void Should_Mark_Entity_As_Deleted()
{
var entity = TestDataProvider.ProvideRandomTestItemModel();
var entity = DatabaseTestDataProvider.ProvideRandomTestItemModel();
Repository.Save(entity);
UnitOfWork.Commit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using BetterModules.Sample.Module.Models;
using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext.EventListeners
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext.EventListeners
{
[TestFixture]
public class SaveOrUpdateEventListenerTests : DatabaseTestBase
{
[Test]
public void Should_Update_Entity_Properties_When_Creating()
{
var entity = TestDataProvider.ProvideRandomTestItemModel();
var entity = DatabaseTestDataProvider.ProvideRandomTestItemModel();
Repository.Save(entity);
UnitOfWork.Commit();

Expand All @@ -26,7 +26,7 @@ public void Should_Update_Entity_Properties_When_Creating()
[Test]
public void Should_Update_Entity_Properties_When_Updating()
{
var entity = TestDataProvider.ProvideRandomTestItemModel();
var entity = DatabaseTestDataProvider.ProvideRandomTestItemModel();
Repository.Save(entity);
UnitOfWork.Commit();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System.Linq;

using Autofac;

using BetterModules.Core.DataAccess;
using BetterModules.Core.DataAccess.DataContext.Fetching;
using BetterModules.Core.Dependencies;
using BetterModules.Sample.Module.Models;

using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext.Fetching
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext.Fetching
{
[TestFixture]
public class DefaultFetchingProviderIntegrationTests : DatabaseTestBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using BetterModules.Core.Exceptions.DataTier;
using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext.Interceptors
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext.Interceptors
{
[TestFixture]
public class StaleInterceptorIntegrationTests : DatabaseTestBase
{
[Test]
public void Should_Create_Version()
{
var model = TestDataProvider.ProvideRandomTestItemModel();
var model = DatabaseTestDataProvider.ProvideRandomTestItemModel();

Assert.AreEqual(model.Version, 0);

Expand All @@ -22,7 +22,7 @@ public void Should_Create_Version()
[Test]
public void Should_Increase_Version_If_Dirty()
{
var model = TestDataProvider.ProvideRandomTestItemModel();
var model = DatabaseTestDataProvider.ProvideRandomTestItemModel();

Assert.AreEqual(model.Version, 0);

Expand All @@ -47,7 +47,7 @@ public void Should_Increase_Version_If_Dirty()
[ExpectedException(typeof (ConcurrentDataException))]
public void Should_Throw_Concurrent_Data_Exception_Saving()
{
var model = TestDataProvider.ProvideRandomTestItemModel();
var model = DatabaseTestDataProvider.ProvideRandomTestItemModel();

Assert.AreEqual(model.Version, 0);

Expand All @@ -65,7 +65,7 @@ public void Should_Throw_Concurrent_Data_Exception_Saving()
[ExpectedException(typeof (ConcurrentDataException))]
public void Should_Throw_Concurrent_Data_Exception_Deleting()
{
var model = TestDataProvider.ProvideRandomTestItemModel();
var model = DatabaseTestDataProvider.ProvideRandomTestItemModel();

Assert.AreEqual(model.Version, 0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Linq;

using BetterModules.Core.DataAccess.DataContext;
using BetterModules.Core.Exceptions.DataTier;
using BetterModules.Sample.Module.Models;

using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext
{
[TestFixture]
public class QueryOverExtensionsIntegrationTests : DatabaseTestBase
Expand All @@ -25,13 +23,13 @@ public void SetUp()
{
isSet = true;

category1 = TestDataProvider.ProvideRandomTestItemCategory();
category1 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();

model1 = TestDataProvider.ProvideRandomTestItemModel(category1);
model1 = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
model1.Name = "QVO_01";
model2 = TestDataProvider.ProvideRandomTestItemModel(category1);
model2 = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
model2.Name = "QVO_02";
model3 = TestDataProvider.ProvideRandomTestItemModel(category1);
model3 = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
model3.Name = "QVO_03";

Repository.Save(model3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using NHibernate.Linq;
using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext
{
[TestFixture]
public class QueryableExtensionsIntegrationTests : DatabaseTestBase
Expand All @@ -22,9 +22,9 @@ public void Should_Return_Correct_Items_FutureWrapper_Count()
[Test]
public void Should_Return_Correct_Items_Future_Count()
{
var category1 = TestDataProvider.ProvideRandomTestItemCategory();
var category2 = TestDataProvider.ProvideRandomTestItemCategory();
var category3 = TestDataProvider.ProvideRandomTestItemCategory();
var category1 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();
var category2 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();
var category3 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();
category1.Name = "QEIT_" + category1.Name.Substring(10);
category2.Name = "QEIT_" + category1.Name.Substring(10);
category3.Name = "QEIT_" + category1.Name.Substring(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using NHibernate.Criterion;
using NUnit.Framework;

namespace BetterModules.Core.Tests.DataAccess.DataContext
namespace BetterModules.Core.Database.Tests.DataAccess.DataContext
{
[TestFixture]
public class RestrictionsExtensionsIntegrationTests : DatabaseTestBase
{
[Test]
public void Should_Filter_Null_Or_Whitespace_Column_Correctly()
{
var category = TestDataProvider.ProvideRandomTestItemCategory();
var category = DatabaseTestDataProvider.ProvideRandomTestItemCategory();
category.Name = " ";

Repository.Save(category);
Expand Down
Loading

0 comments on commit 7d38943

Please sign in to comment.