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
public class CleanupTestDataEventListener : IPostInsertEventListener | |
{ | |
private readonly HashSet<object> _insertedEntities = new HashSet<object>(); | |
public IEnumerable<object> InsertedEntities | |
{ | |
get { return _insertedEntities.Reverse(); } | |
} | |
public void OnPostInsert(PostInsertEvent @event) |
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
[SetUp] | |
public void SetUp() | |
{ | |
_cleanupListener = new CleanupTestDataEventListener(); | |
var cfg = new Configuration() | |
.DataBaseIntegration(x => | |
{ | |
x.Dialect<SQLiteDialect>(); | |
x.ConnectionString = "Data Source=test.db;Version=3;"; |
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
[TearDown] | |
public void TearDown() | |
{ | |
using(var session = CreateSession()) | |
{ | |
using(var tx = session.BeginTransaction()) | |
{ | |
foreach (var entity in _cleanupListener.InsertedEntities) | |
{ | |
session.Delete(entity); |
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
[Test] | |
public void Create_Some_Data() | |
{ | |
var person = new Person{Name = "dsd", Age = 22}; | |
var foo = new Foo {Description = "Testing"}; | |
using(var session = CreateSession()) | |
{ | |
using(var tx = session.BeginTransaction()) | |
{ |
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
NHibernate: INSERT INTO Person (Name, Age, Id) VALUES (@p0, @p1, @p2);@p0 = 'dsd' [Type: String (0)], @p1 = 22 [Type: Int32 (0)], @p2 = 0 [Type: Int32 (0)] | |
NHibernate: INSERT INTO Foo (Description, Id) VALUES (@p0, @p1);@p0 = 'Testing' [Type: String (0)], @p1 = 0 [Type: Int32 (0)] | |
NHibernate: SELECT person_.Id, person_.Name as Name0_, person_.Age as Age0_ FROM Person person_ WHERE person_.Id=@p0;@p0 = 0 [Type: Int32 (0)] | |
NHibernate: SELECT foo_.Id, foo_.Description as Descript2_1_ FROM Foo foo_ WHERE foo_.Id=@p0;@p0 = 0 [Type: Int32 (0)] | |
NHibernate: DELETE FROM Person WHERE Id = @p0;@p0 = 0 [Type: Int32 (0)] | |
NHibernate: DELETE FROM Foo WHERE Id = @p0;@p0 = 0 [Type: Int32 (0)] |
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
// Rhino Mocks | |
var foo = MockRepository.GenerateStub<IFoo>(); | |
var foo = MockRepository.GenerateMock<IFoo>(); | |
var foo = MockRepository.GeneratePartialMock<IFoo>(); | |
var foo = MockRepository.GenerateStrictMock()<IFoo>(); | |
// NSubstitute | |
var foo = Substitute.For<IFoo>(); |
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
[Test] | |
public void Some_Test_Rhino() | |
{ | |
// Arrange | |
var foo = MockRepository.GenerateStub<IFoo>(); | |
var someClass = new SomeClass(foo); | |
// Act | |
someClass.DoWork(); |
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
// Rhino Mocks | |
var foo = MockRepository.GenerateStub<IFoo>(); | |
foo.Stub(x => x.GetValue()) | |
.Return("testing"); | |
// NSubstitute | |
var foo = Substitute.For<IFoo>(); | |
foo.GetValue().Returns("testing"); |
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
public void Foo(int bah) { | |
//if(bah > 1) { | |
if(bah > 2) { | |
} | |
} |
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
//public class Foo { | |
// public void Bah() { | |
// | |
// } | |
//} |
OlderNewer