main
1using gorilla.utility;
2using Machine.Specifications;
3using Rhino.Mocks;
4using solidware.financials.service.orm;
5
6namespace specs.unit.service.orm
7{
8 public class DB4OUnitOfWorkSpecs
9 {
10 public class concern
11 {
12 Establish context = () =>
13 {
14 session = Create.dependency<Connection>();
15 the_context = Create.dependency<Context>();
16 sut = new DB4OUnitOfWork(session, the_context);
17 };
18
19 static protected DB4OUnitOfWork sut;
20 static protected Connection session;
21 static Context the_context;
22 }
23
24 [Subject(typeof(DB4OUnitOfWork))]
25 public class when_disposing_a_unit_of_work_that_has_not_been_committed : concern
26 {
27 It should_roll_back_the_transaction = () =>
28 {
29 session.AssertWasCalled(x => x.Rollback());
30 };
31 //It should_dispose_the_transaction = () =>
32 //{
33 // session.AssertWasCalled(x => x.Dispose());
34 //};
35
36 Because of = () =>
37 {
38 sut.Dispose();
39 };
40 }
41 [Subject(typeof(DB4OUnitOfWork))]
42 public class when_disposing_a_unit_of_work_that_has_been_committed : concern
43 {
44 It should_not_roll_back_the_transaction = () =>
45 {
46 session.AssertWasNotCalled(x => x.Rollback());
47 };
48 //It should_dispose_the_transaction = () =>
49 //{
50 // session.AssertWasCalled(x => x.Dispose());
51 //};
52
53 Because of = () =>
54 {
55 sut.commit();
56 sut.Dispose();
57 };
58 }
59 [Subject(typeof(DB4OUnitOfWork))]
60 public class when_committing_a_unit_of_work : concern
61 {
62 It should_commit_the_transaction = () =>
63 {
64 session.AssertWasCalled(x => x.Commit());
65 };
66
67 Because of = () =>
68 {
69 sut.commit();
70 };
71 }
72 }
73}