This repository has been archived by the owner on Aug 16, 2018. It is now read-only.
forked from sharparchitecture/Sharp-Architecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing NHibernateSession with NHibernateSessionFactoryBuilder, see s…
…harparchitecture#61 * ValidatableObject now requires ValidationContext; * HasUniqueDomainSignatureAttribute now requires ValidationContext; * DataAnnotationsEventListener how provides IServiceProvider with ISession; * TardisBank - use CastleWindsor to register ISession and ISessionFactory; * TardisBank - update CastleWindsor installers.
- Loading branch information
Showing
63 changed files
with
574 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
// ReSharper disable InconsistentNaming | ||
using NUnit.Framework; | ||
|
||
namespace Suteki.TardisBank.Tests.Model | ||
{ | ||
using System; | ||
|
||
using SharpArch.Domain.PersistenceSupport; | ||
using Domain; | ||
using NUnit.Framework; | ||
using SharpArch.NHibernate; | ||
using SharpArch.Testing.NUnit; | ||
using SharpArch.Testing.NUnit.NHibernate; | ||
|
||
using global::Suteki.TardisBank.Domain; | ||
|
||
[TestFixture] | ||
public class ChildTests : RepositoryTestsBase | ||
{ | ||
|
@@ -20,21 +17,21 @@ public class ChildTests : RepositoryTestsBase | |
protected override void LoadTestData() | ||
{ | ||
var parent = new Parent("Mike Hadlow", "[email protected]", "yyy"); | ||
NHibernateSession.Current.Save(parent); | ||
Session.Save(parent); | ||
|
||
parentId = parent.Id; | ||
|
||
var child = parent.CreateChild("Leo", "leohadlow", "xxx"); | ||
NHibernateSession.Current.Save(child); | ||
RepositoryTestsHelper.FlushSessionAndEvict(child); | ||
RepositoryTestsHelper.FlushSessionAndEvict(parent); | ||
Session.Save(child); | ||
FlushSessionAndEvict(child); | ||
FlushSessionAndEvict(parent); | ||
this.childId = child.Id; | ||
} | ||
|
||
[Test] | ||
public void Should_be_able_to_create_and_retrieve_a_child() | ||
{ | ||
var child = new LinqRepository<Child>().Get(childId); | ||
var child = new LinqRepository<Child>(TransactionManager, Session).Get(childId); | ||
child.Name.ShouldEqual("Leo"); | ||
child.UserName.ShouldEqual("leohadlow"); | ||
child.ParentId.ShouldEqual(parentId); | ||
|
@@ -45,7 +42,7 @@ public void Should_be_able_to_create_and_retrieve_a_child() | |
[Test] | ||
public void Should_be_able_to_add_schedule_to_account() | ||
{ | ||
var childRepository = new LinqRepository<Child>(); | ||
var childRepository = new LinqRepository<Child>(TransactionManager, Session); | ||
var childToTestOn = childRepository.Get(childId); | ||
childToTestOn.Account.AddPaymentSchedule(DateTime.UtcNow, Interval.Week, 10, "Weekly pocket money"); | ||
FlushSessionAndEvict(childToTestOn); | ||
|
@@ -57,7 +54,7 @@ public void Should_be_able_to_add_schedule_to_account() | |
[Test] | ||
public void Should_be_able_to_add_transaction_to_account() | ||
{ | ||
var childRepository = new LinqRepository<Child>(); | ||
var childRepository = new LinqRepository<Child>(TransactionManager, Session); | ||
var childToTestOn = childRepository.Get(childId); | ||
childToTestOn.ReceivePayment(10, "Reward"); | ||
FlushSessionAndEvict(childToTestOn); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,15 @@ public class MessageTests : RepositoryTestsBase | |
protected override void LoadTestData() | ||
{ | ||
User user = new Parent("Dad", "[email protected]", "xxx"); | ||
NHibernateSession.Current.Save(user); | ||
Session.Save(user); | ||
this.FlushSessionAndEvict(user); | ||
userId = user.Id; | ||
} | ||
|
||
[Test] | ||
public void Should_be_able_to_add_a_message_to_a_user() | ||
{ | ||
var parentRepository = new LinqRepository<Parent>(); | ||
var parentRepository = new LinqRepository<Parent>(TransactionManager, Session); | ||
User userToTestWith = parentRepository.Get(userId); | ||
|
||
userToTestWith.SendMessage("some message"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ public class ParentTests : RepositoryTestsBase | |
protected override void LoadTestData() | ||
{ | ||
var parent = new Parent(name: "Mike Hadlow", userName: string.Format("{0}@yahoo.com", "mike"), password: "yyy"); | ||
NHibernateSession.Current.Save(parent); | ||
Session.Save(parent); | ||
this.FlushSessionAndEvict(parent); | ||
parentId = parent.Id; | ||
} | ||
|
||
[Test] | ||
public void Should_be_able_to_create_and_retrieve_Parent() | ||
{ | ||
var parent = new LinqRepository<Parent>().Get(parentId); | ||
var parent = new LinqRepository<Parent>(TransactionManager, Session).Get(parentId); | ||
parent.ShouldNotBeNull(); | ||
parent.Name.ShouldEqual("Mike Hadlow"); | ||
parent.UserName.ShouldEqual("[email protected]"); | ||
|
@@ -34,7 +34,7 @@ public void Should_be_able_to_create_and_retrieve_Parent() | |
[Test] | ||
public void Should_be_able_to_add_a_child_to_a_parent() | ||
{ | ||
var linqRepository = new LinqRepository<Parent>(); | ||
var linqRepository = new LinqRepository<Parent>(TransactionManager, Session); | ||
var savedParent = linqRepository.Get(parentId); | ||
savedParent.CreateChild("jim", "jim123", "passw0rd1"); | ||
savedParent.CreateChild("jenny", "jenny123", "passw0rd2"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,26 +19,26 @@ public class UserTests : RepositoryTestsBase | |
protected override void LoadTestData() | ||
{ | ||
var mike = new Parent("Mike Hadlow", "[email protected]", "yyy"); | ||
NHibernateSession.Current.Save(mike); | ||
Session.Save(mike); | ||
|
||
var leo = mike.CreateChild("Leo", "leohadlow", "xxx"); | ||
var yuna = mike.CreateChild("Yuna", "yunahadlow", "xxx"); | ||
NHibernateSession.Current.Save(leo); | ||
NHibernateSession.Current.Save(yuna); | ||
Session.Save(leo); | ||
Session.Save(yuna); | ||
|
||
var john = new Parent("John Robinson", "[email protected]", "yyy"); | ||
NHibernateSession.Current.Save(john); | ||
Session.Save(john); | ||
|
||
var jim = john.CreateChild("Jim", "jimrobinson", "xxx"); | ||
NHibernateSession.Current.Save(jim); | ||
Session.Save(jim); | ||
|
||
NHibernateSession.Current.Flush(); | ||
Session.Flush(); | ||
} | ||
|
||
[Test] | ||
public void Should_be_able_to_treat_Parents_and_Children_Polymorphically() | ||
{ | ||
var users = NHibernateSession.Current.Query<User>().ToArray(); | ||
var users = Session.Query<User>().ToArray(); | ||
|
||
users.Length.ShouldEqual(5); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.