DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | List of all members
Deveel.Data.Diagnostics.EventsTests Class Reference
Inheritance diagram for Deveel.Data.Diagnostics.EventsTests:
Deveel.Data.ContextBasedTest

Public Member Functions

void AttachRouter ()
 
void RouteError ()
 
void FireAtLowerLevelAndListenAtHighest ()
 
void RouteOnlyOnce ()
 
void RouteOnlyOnceForSameEventType ()
 
void RouteTwiceForSameEventType ()
 
void RouteOneRegisteredMany ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Additional Inherited Members

- Protected Member Functions inherited from Deveel.Data.ContextBasedTest
virtual void RegisterServices (ServiceContainer container)
 
virtual ISystem CreateSystem ()
 
virtual IDatabase CreateDatabase (ISystem system, IConfiguration configuration)
 
virtual ISession CreateAdminSession (IDatabase database)
 
virtual IQuery CreateQuery (ISession session)
 
ISession CreateUserSession (string userName, string password)
 
virtual void OnSetUp (string testName)
 
virtual void OnTearDown ()
 
- Protected Attributes inherited from Deveel.Data.ContextBasedTest
const string AdminUserName = "SA"
 
const string AdminPassword = "1234567890"
 
const string DatabaseName = "testdb"
 
- Properties inherited from Deveel.Data.ContextBasedTest
virtual bool SingleContext [get]
 
IQuery Query [get, private set]
 
ISystem System [get, private set]
 
IDatabase Database [get, private set]
 
ISession Session [get, private set]
 

Detailed Description

Definition at line 8 of file EventsTests.cs.

Member Function Documentation

void Deveel.Data.Diagnostics.EventsTests.AttachRouter ( )
inline

Definition at line 10 of file EventsTests.cs.

10  {
11  IEvent firedEvent = null;
12  Assert.DoesNotThrow(() => Query.Route<ErrorEvent>(@event => firedEvent = @event));
13  Assert.IsNull(firedEvent);
14  }
void Deveel.Data.Diagnostics.EventsTests.FireAtLowerLevelAndListenAtHighest ( )
inline

Definition at line 35 of file EventsTests.cs.

35  {
36  var reset = new AutoResetEvent(false);
37 
38  IEvent fired = null;
39  System.Context.Route<InformationEvent>(e => {
40  fired = e;
41  reset.Set();
42  });
43 
44  Query.OnVerbose("Test Message");
45 
46  reset.WaitOne(300);
47 
48  Assert.IsNotNull(fired);
49  Assert.IsInstanceOf<InformationEvent>(fired);
50 
51  var infoEvent = (InformationEvent) fired;
52  Assert.AreEqual(InformationLevel.Verbose, infoEvent.Level);
53  Assert.AreEqual("Test Message", infoEvent.Message);
54  }
void Deveel.Data.Diagnostics.EventsTests.RouteError ( )
inline

Definition at line 17 of file EventsTests.cs.

17  {
18  var reset = new AutoResetEvent(false);
19 
20  IEvent firedEvent = null;
21  Query.Route<ErrorEvent>(e => {
22  firedEvent = e;
23  reset.Set();
24  });
25 
26  Query.OnError(new Exception("Test Error"));
27 
28  reset.WaitOne();
29 
30  Assert.IsNotNull(firedEvent);
31  Assert.IsInstanceOf<ErrorEvent>(firedEvent);
32  }
void Deveel.Data.Diagnostics.EventsTests.RouteOneRegisteredMany ( )
inline

Definition at line 138 of file EventsTests.cs.

138  {
139  var reset = new AutoResetEvent(false);
140 
141  QueryEvent a = null, b = null;
142  System.Context.Route<QueryEvent>(e => a = e);
143  System.Context.Route<QueryEvent>(e => b = e);
144 
145  IEvent fired = null;
146  System.Context.Route<InformationEvent>(e => {
147  fired = e;
148  reset.Set();
149  });
150 
151  Query.OnVerbose("Test Message");
152 
153  reset.WaitOne(300);
154 
155  Assert.IsNotNull(fired);
156  Assert.IsInstanceOf<InformationEvent>(fired);
157 
158  Assert.IsNull(a);
159  Assert.IsNull(b);
160 
161  var infoEvent = (InformationEvent) fired;
162  Assert.AreEqual(InformationLevel.Verbose, infoEvent.Level);
163  Assert.AreEqual("Test Message", infoEvent.Message);
164  }
void Deveel.Data.Diagnostics.EventsTests.RouteOnlyOnce ( )
inline

Definition at line 57 of file EventsTests.cs.

57  {
58  var reset1 = new AutoResetEvent(false);
59  var reset2 = new AutoResetEvent(false);
60 
61  IEvent systemFired = null;
62  System.Context.Route<InformationEvent>(e => {
63  systemFired = e;
64  reset1.Set();
65  });
66 
67  IEvent sessionFired = null;
68 
69  Session.Context.Route<ErrorEvent>(e => {
70  sessionFired = e;
71  reset2.Set();
72  });
73 
74  Query.OnVerbose("Test Message");
75 
76  reset1.WaitOne(300);
77  reset2.WaitOne(300);
78 
79  Assert.IsNotNull(systemFired);
80  Assert.IsNull(sessionFired);
81  }
new ISessionContext Context
Definition: ISession.cs:48
void Deveel.Data.Diagnostics.EventsTests.RouteOnlyOnceForSameEventType ( )
inline

Definition at line 84 of file EventsTests.cs.

84  {
85  var reset1 = new AutoResetEvent(false);
86  var reset2 = new AutoResetEvent(false);
87 
88  IEvent systemFired = null;
89  System.Context.Route<InformationEvent>(e => {
90  systemFired = e;
91  reset1.Set();
92  });
93 
94  IEvent sessionFired = null;
95 
96  Session.Context.Route<InformationEvent>(e => {
97  sessionFired = e;
98  reset2.Set();
99  }, e => e.Level == InformationLevel.Debug);
100 
101  Query.OnVerbose("Test Message");
102 
103  reset1.WaitOne(300);
104  reset2.WaitOne(300);
105 
106  Assert.IsNotNull(systemFired);
107  Assert.IsNull(sessionFired);
108  }
new ISessionContext Context
Definition: ISession.cs:48
void Deveel.Data.Diagnostics.EventsTests.RouteTwiceForSameEventType ( )
inline

Definition at line 111 of file EventsTests.cs.

111  {
112  var reset1 = new AutoResetEvent(false);
113  var reset2 = new AutoResetEvent(false);
114 
115  IEvent systemFired = null;
116  System.Context.Route<InformationEvent>(e => {
117  systemFired = e;
118  reset1.Set();
119  });
120 
121  IEvent sessionFired = null;
122 
123  Session.Context.Route<InformationEvent>(e => {
124  sessionFired = e;
125  reset2.Set();
126  });
127 
128  Query.OnVerbose("Test Message");
129 
130  reset1.WaitOne(300);
131  reset2.WaitOne(300);
132 
133  Assert.IsNotNull(systemFired);
134  Assert.IsNotNull(sessionFired);
135  }
new ISessionContext Context
Definition: ISession.cs:48

The documentation for this class was generated from the following file: