From 7d38943a30cf7c68623091e4c2c67f5f71b134b1 Mon Sep 17 00:00:00 2001 From: Audrunas Matonis Date: Mon, 2 Mar 2015 18:13:24 +0200 Subject: [PATCH] BetterModules: created new project for database integration tests --- .../App_Data/BetterModulesTestsDataSet.mdf | Bin .../BetterModulesTestsDataSet_log.ldf | Bin .../BetterModules.Core.Database.Tests.csproj | 168 ++++++++++++++++++ .../Config/connectionStrings.config | 5 + .../Config/modules.config | 8 + .../DeleteEventListenerIntegrationTests.cs | 4 +- .../SaveOrUpdateEventListenerTests.cs | 6 +- ...DefaultFetchingProviderIntegrationTests.cs | 5 +- .../StaleInterceptorIntegrationTests.cs | 10 +- .../QueryOverExtensionsIntegrationTests.cs | 12 +- .../QueryableExtensionsIntegrationTests.cs | 8 +- .../RestrictionsExtensionsIntegrationTests.cs | 4 +- .../DefaultRepositoryIntegrationTests.cs | 29 ++- .../DatabaseTestBase.cs | 23 ++- .../Models/EntityMapBaseIntegrationTests.cs | 2 +- .../EntitySubClassMapBaseIntergrationTests.cs | 2 +- .../Properties/AssemblyInfo.cs | 36 ++++ .../DatabaseRandomTestDataProvider.cs | 25 +++ .../Migrations/TestDatabaseInitializer.cs | 6 +- .../TestHelpers/TestDatabaseCreator.cs | 2 +- BetterModules.Core.Database.Tests/app.config | 22 +++ .../packages.config | 11 ++ .../BetterModules.Core.Tests.csproj | 26 +-- .../EventListenerHelperTests.cs | 2 +- BetterModules.Core.Tests/TestBase.cs | 2 +- .../TestHelpers/RandomTestDataProvider.cs | 19 -- BetterModules.sln | 7 + packages/repositories.config | 2 + 28 files changed, 345 insertions(+), 101 deletions(-) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/App_Data/BetterModulesTestsDataSet.mdf (100%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/App_Data/BetterModulesTestsDataSet_log.ldf (100%) create mode 100644 BetterModules.Core.Database.Tests/BetterModules.Core.Database.Tests.csproj create mode 100644 BetterModules.Core.Database.Tests/Config/connectionStrings.config create mode 100644 BetterModules.Core.Database.Tests/Config/modules.config rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs (82%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs (89%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs (98%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs (82%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs (88%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs (80%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs (85%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DataAccess/DefaultRepositoryIntegrationTests.cs (91%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/DatabaseTestBase.cs (71%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/Models/EntityMapBaseIntegrationTests.cs (96%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/Models/EntitySubClassMapBaseIntergrationTests.cs (96%) create mode 100644 BetterModules.Core.Database.Tests/Properties/AssemblyInfo.cs create mode 100644 BetterModules.Core.Database.Tests/TestHelpers/DatabaseRandomTestDataProvider.cs rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/TestHelpers/Migrations/TestDatabaseInitializer.cs (97%) rename {BetterModules.Core.Tests => BetterModules.Core.Database.Tests}/TestHelpers/TestDatabaseCreator.cs (98%) create mode 100644 BetterModules.Core.Database.Tests/app.config create mode 100644 BetterModules.Core.Database.Tests/packages.config diff --git a/BetterModules.Core.Tests/App_Data/BetterModulesTestsDataSet.mdf b/BetterModules.Core.Database.Tests/App_Data/BetterModulesTestsDataSet.mdf similarity index 100% rename from BetterModules.Core.Tests/App_Data/BetterModulesTestsDataSet.mdf rename to BetterModules.Core.Database.Tests/App_Data/BetterModulesTestsDataSet.mdf diff --git a/BetterModules.Core.Tests/App_Data/BetterModulesTestsDataSet_log.ldf b/BetterModules.Core.Database.Tests/App_Data/BetterModulesTestsDataSet_log.ldf similarity index 100% rename from BetterModules.Core.Tests/App_Data/BetterModulesTestsDataSet_log.ldf rename to BetterModules.Core.Database.Tests/App_Data/BetterModulesTestsDataSet_log.ldf diff --git a/BetterModules.Core.Database.Tests/BetterModules.Core.Database.Tests.csproj b/BetterModules.Core.Database.Tests/BetterModules.Core.Database.Tests.csproj new file mode 100644 index 0000000..d408a7b --- /dev/null +++ b/BetterModules.Core.Database.Tests/BetterModules.Core.Database.Tests.csproj @@ -0,0 +1,168 @@ + + + + + Debug + AnyCPU + {890E75A2-68E2-4579-91EC-64DEBB51723D} + Library + Properties + BetterModules.Core.Database.Tests + BetterModules.Core.Database.Tests + v4.5 + 512 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + ..\ + true + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\packages\Autofac.3.1.5\lib\net40\Autofac.dll + + + ..\packages\FluentMigrator.1.0.6.0\lib\40\FluentMigrator.dll + + + ..\packages\FluentNHibernate.1.3.0.733\lib\FluentNHibernate.dll + + + ..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll + + + ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + + ..\packages\NHibernate.3.3.3.4001\lib\Net35\NHibernate.dll + + + False + ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + BetterModulesTestsDataSet.mdf + Always + + + + + + Designer + Always + + + Designer + Always + + + + + + + + + False + Microsoft .NET Framework 4.5 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + + + {bfe98842-c880-4e23-9898-32acb2e95a2f} + BetterModules.Core.Tests + + + {c97b2899-5ac5-4528-b205-478d4183676d} + BetterModules.Core + + + {ed95b78c-2448-4096-a89c-a2ca3916783a} + BetterModules.Sample.Module + + + + + + + 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}. + + + + + \ No newline at end of file diff --git a/BetterModules.Core.Database.Tests/Config/connectionStrings.config b/BetterModules.Core.Database.Tests/Config/connectionStrings.config new file mode 100644 index 0000000..30bd173 --- /dev/null +++ b/BetterModules.Core.Database.Tests/Config/connectionStrings.config @@ -0,0 +1,5 @@ + + + + + diff --git a/BetterModules.Core.Database.Tests/Config/modules.config b/BetterModules.Core.Database.Tests/Config/modules.config new file mode 100644 index 0000000..a3f15b5 --- /dev/null +++ b/BetterModules.Core.Database.Tests/Config/modules.config @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs similarity index 82% rename from BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs index b993ad9..557ca92 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/EventListeners/DeleteEventListenerIntegrationTests.cs @@ -3,7 +3,7 @@ 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 @@ -11,7 +11,7 @@ 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(); diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs similarity index 89% rename from BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs index 1df6a61..d3697e3 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/EventListeners/SaveOrUpdateEventListenerTests.cs @@ -3,7 +3,7 @@ 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 @@ -11,7 +11,7 @@ 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(); @@ -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(); diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs similarity index 98% rename from BetterModules.Core.Tests/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs index cbb6181..28cada0 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/Fetching/DefaultFetchingProviderIntegrationTests.cs @@ -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 diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs similarity index 82% rename from BetterModules.Core.Tests/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs index 3debab1..1ed174a 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/Interceptors/StaleInterceptorIntegrationTests.cs @@ -1,7 +1,7 @@ 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 @@ -9,7 +9,7 @@ public class StaleInterceptorIntegrationTests : DatabaseTestBase [Test] public void Should_Create_Version() { - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Assert.AreEqual(model.Version, 0); @@ -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); @@ -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); @@ -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); diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs similarity index 88% rename from BetterModules.Core.Tests/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs index ce7ddfc..514d535 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/QueryOverExtensionsIntegrationTests.cs @@ -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 @@ -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); diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs similarity index 80% rename from BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs index 8c43b3f..6d162e0 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/QueryableExtensionsIntegrationTests.cs @@ -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 @@ -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); diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs similarity index 85% rename from BetterModules.Core.Tests/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs index 57d33fd..a6551de 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DataContext/RestrictionsExtensionsIntegrationTests.cs @@ -3,7 +3,7 @@ using NHibernate.Criterion; using NUnit.Framework; -namespace BetterModules.Core.Tests.DataAccess.DataContext +namespace BetterModules.Core.Database.Tests.DataAccess.DataContext { [TestFixture] public class RestrictionsExtensionsIntegrationTests : DatabaseTestBase @@ -11,7 +11,7 @@ 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); diff --git a/BetterModules.Core.Tests/DataAccess/DefaultRepositoryIntegrationTests.cs b/BetterModules.Core.Database.Tests/DataAccess/DefaultRepositoryIntegrationTests.cs similarity index 91% rename from BetterModules.Core.Tests/DataAccess/DefaultRepositoryIntegrationTests.cs rename to BetterModules.Core.Database.Tests/DataAccess/DefaultRepositoryIntegrationTests.cs index 9b58885..343c188 100644 --- a/BetterModules.Core.Tests/DataAccess/DefaultRepositoryIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/DataAccess/DefaultRepositoryIntegrationTests.cs @@ -1,19 +1,16 @@ using System; using System.Linq; - using Autofac; - using BetterModules.Core.DataAccess; using BetterModules.Core.DataAccess.DataContext; using BetterModules.Core.Dependencies; using BetterModules.Core.Exceptions.DataTier; using BetterModules.Sample.Module; using BetterModules.Sample.Module.Models; - using NHibernate.Proxy.DynamicProxy; using NUnit.Framework; -namespace BetterModules.Core.Tests.DataAccess +namespace BetterModules.Core.Database.Tests.DataAccess { [TestFixture] public class DefaultRepositoryIntegrationTests : DatabaseTestBase @@ -32,15 +29,15 @@ public void SetUp() { isSet = true; - category1 = TestDataProvider.ProvideRandomTestItemCategory(); + category1 = DatabaseTestDataProvider.ProvideRandomTestItemCategory(); - model1 = TestDataProvider.ProvideRandomTestItemModel(category1); + model1 = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1); model1.Name = "DRT_01"; - model2 = TestDataProvider.ProvideRandomTestItemModel(category1); + model2 = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1); model2.Name = "DRT_02"; - model3 = TestDataProvider.ProvideRandomTestItemModel(category1); + model3 = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1); model3.Name = "DRT_03"; - deletedModel = TestDataProvider.ProvideRandomTestItemModel(category1); + deletedModel = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1); deletedModel.Name = "DRT_04"; Repository.Save(model3); @@ -239,7 +236,7 @@ public void Should_Check_If_Deleted_Record_Not_Exists() [Test] public void Should_Save_Entity() { - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); @@ -250,7 +247,7 @@ public void Should_Save_Entity() [Test] public void Should_Delete_Entity_By_Id_NotAsProxy() { - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); @@ -267,7 +264,7 @@ public void Should_Delete_Entity_By_Id_NotAsProxy() [Test] public void Should_Delete_Entity_By_Id_AsProxy() { - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); @@ -284,7 +281,7 @@ public void Should_Delete_Entity_By_Id_AsProxy() [Test] public void Should_Delete_Entity() { - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); @@ -302,7 +299,7 @@ public void Should_Delete_Entity() public void Should_Attach_Entity() { // Create entity - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); @@ -330,7 +327,7 @@ public void Should_Attach_Entity() public void Should_Detach_Entity() { // Create entity - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); @@ -357,7 +354,7 @@ public void Should_Detach_Entity() public void Should_Refresh_Entity() { // Create entity - var model = TestDataProvider.ProvideRandomTestItemModel(); + var model = DatabaseTestDataProvider.ProvideRandomTestItemModel(); Repository.Save(model); UnitOfWork.Commit(); diff --git a/BetterModules.Core.Tests/DatabaseTestBase.cs b/BetterModules.Core.Database.Tests/DatabaseTestBase.cs similarity index 71% rename from BetterModules.Core.Tests/DatabaseTestBase.cs rename to BetterModules.Core.Database.Tests/DatabaseTestBase.cs index dc3b173..808ee83 100644 --- a/BetterModules.Core.Tests/DatabaseTestBase.cs +++ b/BetterModules.Core.Database.Tests/DatabaseTestBase.cs @@ -1,17 +1,18 @@ using System.Data.SqlClient; - using Autofac; - using BetterModules.Core.Configuration; using BetterModules.Core.DataAccess; using BetterModules.Core.DataAccess.DataContext; -using BetterModules.Core.Tests.TestHelpers; -using BetterModules.Core.Tests.TestHelpers.Migrations; +using BetterModules.Core.Database.Tests.TestHelpers; +using BetterModules.Core.Database.Tests.TestHelpers.Migrations; +using BetterModules.Core.Tests; -namespace BetterModules.Core.Tests +namespace BetterModules.Core.Database.Tests { public abstract class DatabaseTestBase : TestBase { + private DatabaseRandomTestDataProvider testDataProvider; + private static LocalDatabase database; private IRepository repository; @@ -64,5 +65,17 @@ protected override void OnTextFixtureDown() base.OnTextFixtureDown(); } + + public virtual DatabaseRandomTestDataProvider DatabaseTestDataProvider + { + get + { + if (testDataProvider == null) + { + testDataProvider = new DatabaseRandomTestDataProvider(); + } + return testDataProvider; + } + } } } diff --git a/BetterModules.Core.Tests/Models/EntityMapBaseIntegrationTests.cs b/BetterModules.Core.Database.Tests/Models/EntityMapBaseIntegrationTests.cs similarity index 96% rename from BetterModules.Core.Tests/Models/EntityMapBaseIntegrationTests.cs rename to BetterModules.Core.Database.Tests/Models/EntityMapBaseIntegrationTests.cs index bcd2b35..de355ce 100644 --- a/BetterModules.Core.Tests/Models/EntityMapBaseIntegrationTests.cs +++ b/BetterModules.Core.Database.Tests/Models/EntityMapBaseIntegrationTests.cs @@ -3,7 +3,7 @@ using BetterModules.Sample.Module.Models; using NUnit.Framework; -namespace BetterModules.Core.Tests.Models +namespace BetterModules.Core.Database.Tests.Models { [TestFixture] public class EntityMapBaseIntegrationTests : DatabaseTestBase diff --git a/BetterModules.Core.Tests/Models/EntitySubClassMapBaseIntergrationTests.cs b/BetterModules.Core.Database.Tests/Models/EntitySubClassMapBaseIntergrationTests.cs similarity index 96% rename from BetterModules.Core.Tests/Models/EntitySubClassMapBaseIntergrationTests.cs rename to BetterModules.Core.Database.Tests/Models/EntitySubClassMapBaseIntergrationTests.cs index 9b1d395..a9ed96e 100644 --- a/BetterModules.Core.Tests/Models/EntitySubClassMapBaseIntergrationTests.cs +++ b/BetterModules.Core.Database.Tests/Models/EntitySubClassMapBaseIntergrationTests.cs @@ -3,7 +3,7 @@ using BetterModules.Sample.Module.Models; using NUnit.Framework; -namespace BetterModules.Core.Tests.Models +namespace BetterModules.Core.Database.Tests.Models { [TestFixture] public class EntitySubClassMapBaseIntergrationTests : DatabaseTestBase diff --git a/BetterModules.Core.Database.Tests/Properties/AssemblyInfo.cs b/BetterModules.Core.Database.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4b09bb4 --- /dev/null +++ b/BetterModules.Core.Database.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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("BetterModules.Core.Database.Integration.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BetterModules.Core.Database.Integration.Tests")] +[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("617b4a9a-738e-48f6-b76d-c7976e44c525")] + +// 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")] diff --git a/BetterModules.Core.Database.Tests/TestHelpers/DatabaseRandomTestDataProvider.cs b/BetterModules.Core.Database.Tests/TestHelpers/DatabaseRandomTestDataProvider.cs new file mode 100644 index 0000000..1b191ed --- /dev/null +++ b/BetterModules.Core.Database.Tests/TestHelpers/DatabaseRandomTestDataProvider.cs @@ -0,0 +1,25 @@ +using BetterModules.Sample.Module.Models; + +namespace BetterModules.Core.Database.Tests.TestHelpers +{ + public class DatabaseRandomTestDataProvider : Core.Tests.TestHelpers.RandomTestDataProvider + { + public TestItemModel ProvideRandomTestItemModel(TestItemCategory category = null) + { + var model = new TestItemModel(); + model.Name = ProvideRandomString(); + + model.Category = category ?? ProvideRandomTestItemCategory(); + + return model; + } + + public TestItemCategory ProvideRandomTestItemCategory() + { + var model = new TestItemCategory(); + model.Name = ProvideRandomString(); + + return model; + } + } +} diff --git a/BetterModules.Core.Tests/TestHelpers/Migrations/TestDatabaseInitializer.cs b/BetterModules.Core.Database.Tests/TestHelpers/Migrations/TestDatabaseInitializer.cs similarity index 97% rename from BetterModules.Core.Tests/TestHelpers/Migrations/TestDatabaseInitializer.cs rename to BetterModules.Core.Database.Tests/TestHelpers/Migrations/TestDatabaseInitializer.cs index 63c1667..cb35808 100644 --- a/BetterModules.Core.Tests/TestHelpers/Migrations/TestDatabaseInitializer.cs +++ b/BetterModules.Core.Database.Tests/TestHelpers/Migrations/TestDatabaseInitializer.cs @@ -1,16 +1,12 @@ using System.Collections.Generic; using System.Data.SqlClient; - using BetterModules.Core.DataAccess.DataContext.Migrations; using BetterModules.Core.Modules; - using BetterModules.Sample.Module; - using Moq; - using NUnit.Framework; -namespace BetterModules.Core.Tests.TestHelpers.Migrations +namespace BetterModules.Core.Database.Tests.TestHelpers.Migrations { public class TestDatabaseInitializer { diff --git a/BetterModules.Core.Tests/TestHelpers/TestDatabaseCreator.cs b/BetterModules.Core.Database.Tests/TestHelpers/TestDatabaseCreator.cs similarity index 98% rename from BetterModules.Core.Tests/TestHelpers/TestDatabaseCreator.cs rename to BetterModules.Core.Database.Tests/TestHelpers/TestDatabaseCreator.cs index 781a994..b9af065 100644 --- a/BetterModules.Core.Tests/TestHelpers/TestDatabaseCreator.cs +++ b/BetterModules.Core.Database.Tests/TestHelpers/TestDatabaseCreator.cs @@ -10,7 +10,7 @@ using BetterModules.Core.Modules; using Moq; -namespace BetterModules.Core.Tests.TestHelpers +namespace BetterModules.Core.Database.Tests.TestHelpers { public class LocalDatabase : IDisposable { diff --git a/BetterModules.Core.Database.Tests/app.config b/BetterModules.Core.Database.Tests/app.config new file mode 100644 index 0000000..221738a --- /dev/null +++ b/BetterModules.Core.Database.Tests/app.config @@ -0,0 +1,22 @@ + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/BetterModules.Core.Database.Tests/packages.config b/BetterModules.Core.Database.Tests/packages.config new file mode 100644 index 0000000..6e27d0a --- /dev/null +++ b/BetterModules.Core.Database.Tests/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/BetterModules.Core.Tests/BetterModules.Core.Tests.csproj b/BetterModules.Core.Tests/BetterModules.Core.Tests.csproj index 9f51edb..4576eea 100644 --- a/BetterModules.Core.Tests/BetterModules.Core.Tests.csproj +++ b/BetterModules.Core.Tests/BetterModules.Core.Tests.csproj @@ -14,6 +14,7 @@ ..\ true + false publish\ true Disk @@ -26,7 +27,6 @@ true 0 1.0.0.%2a - false false true @@ -88,23 +88,11 @@ - - - - - - - - - - - - @@ -121,18 +109,10 @@ - - - Always - - - Always - BetterModulesTestsDataSet.mdf - Always @@ -156,9 +136,7 @@ BetterModules.Sample.Module - - - + False diff --git a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs b/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs index f3da8a7..0f2af8c 100644 --- a/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs +++ b/BetterModules.Core.Tests/DataAccess/DataContext/EventListeners/EventListenerHelperTests.cs @@ -87,7 +87,7 @@ private void EnsureModificationPropertiesUntouched(TestItemModel entity) private TestItemModel CreateEntity() { - var entity =TestDataProvider.ProvideRandomTestItemModel(); + var entity = new TestItemModel(); entity.CreatedByUser = entity.ModifiedByUser = entity.DeletedByUser = null; entity.CreatedOn = entity.ModifiedOn = DateTime.MinValue; entity.DeletedOn = null; diff --git a/BetterModules.Core.Tests/TestBase.cs b/BetterModules.Core.Tests/TestBase.cs index 060dadf..7d74601 100644 --- a/BetterModules.Core.Tests/TestBase.cs +++ b/BetterModules.Core.Tests/TestBase.cs @@ -35,7 +35,7 @@ protected TestBase() } } - public RandomTestDataProvider TestDataProvider + public virtual RandomTestDataProvider TestDataProvider { get { diff --git a/BetterModules.Core.Tests/TestHelpers/RandomTestDataProvider.cs b/BetterModules.Core.Tests/TestHelpers/RandomTestDataProvider.cs index f76d048..ee3d3a8 100644 --- a/BetterModules.Core.Tests/TestHelpers/RandomTestDataProvider.cs +++ b/BetterModules.Core.Tests/TestHelpers/RandomTestDataProvider.cs @@ -1,6 +1,5 @@ using System; using System.Text; -using BetterModules.Sample.Module.Models; namespace BetterModules.Core.Tests.TestHelpers { @@ -43,23 +42,5 @@ public DateTime ProvideRandomDateTime() return new DateTime(ProvideRandomNumber(1990, 2019), ProvideRandomNumber(1, 12), ProvideRandomNumber(1, 29), ProvideRandomNumber(0, 23), ProvideRandomNumber(0, 59), ProvideRandomNumber(0, 59)); } - - public TestItemModel ProvideRandomTestItemModel(TestItemCategory category = null) - { - var model = new TestItemModel(); - model.Name = ProvideRandomString(); - - model.Category = category ?? ProvideRandomTestItemCategory(); - - return model; - } - - public TestItemCategory ProvideRandomTestItemCategory() - { - var model = new TestItemCategory(); - model.Name = ProvideRandomString(); - - return model; - } } } diff --git a/BetterModules.sln b/BetterModules.sln index 6c5aa52..cea5306 100644 --- a/BetterModules.sln +++ b/BetterModules.sln @@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterModules.Core", "Bette EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterModules.Core.Web", "BetterModules.Core.Web\BetterModules.Core.Web.csproj", "{C8588325-B702-4785-834F-313C19562871}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterModules.Core.Database.Tests", "BetterModules.Core.Database.Tests\BetterModules.Core.Database.Tests.csproj", "{890E75A2-68E2-4579-91EC-64DEBB51723D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -73,6 +75,10 @@ Global {C8588325-B702-4785-834F-313C19562871}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8588325-B702-4785-834F-313C19562871}.Release|Any CPU.ActiveCfg = Release|Any CPU {C8588325-B702-4785-834F-313C19562871}.Release|Any CPU.Build.0 = Release|Any CPU + {890E75A2-68E2-4579-91EC-64DEBB51723D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {890E75A2-68E2-4579-91EC-64DEBB51723D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {890E75A2-68E2-4579-91EC-64DEBB51723D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {890E75A2-68E2-4579-91EC-64DEBB51723D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,5 +90,6 @@ Global {523F9A3E-B266-4863-91C4-08690044A852} = {A57EDF2D-6AA0-4BCB-869D-4FADF32CF1B9} {BFE98842-C880-4E23-9898-32ACB2E95A2F} = {4F4EE6BB-6437-4AAB-86B8-5C0C6F306D1B} {1646AD68-8EC8-4109-B538-E725C5E2A53B} = {4F4EE6BB-6437-4AAB-86B8-5C0C6F306D1B} + {890E75A2-68E2-4579-91EC-64DEBB51723D} = {4F4EE6BB-6437-4AAB-86B8-5C0C6F306D1B} EndGlobalSection EndGlobal diff --git a/packages/repositories.config b/packages/repositories.config index 82dea46..3ab4b12 100644 --- a/packages/repositories.config +++ b/packages/repositories.config @@ -1,5 +1,7 @@  + +