public void ProperCountsSingleTest() { var exception = (Exception)null; var triggered = false; using (var @event = new FbRemoteEvent(Connection.ConnectionString)) { @event.RemoteEventError += (sender, e) => { exception = e.Error; }; @event.RemoteEventCounts += (sender, e) => { triggered = e.Name == "test" && e.Counts == 5; }; @event.Open(); @event.QueueEvents("test"); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "execute block as begin post_event 'test'; post_event 'test'; post_event 'test'; post_event 'test'; post_event 'test'; end"; cmd.ExecuteNonQuery(); Thread.Sleep(2000); } Assert.IsNull(exception); Assert.IsTrue(triggered); } }
public void CancelTest() { var exception = (Exception)null; var triggered = 0; using (var @event = new FbRemoteEvent(Connection.ConnectionString)) { @event.RemoteEventError += (sender, e) => { exception = e.Error; }; @event.RemoteEventCounts += (sender, e) => { triggered++; }; @event.Open(); @event.QueueEvents("test"); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "execute block as begin post_event 'test'; end"; cmd.ExecuteNonQuery(); Thread.Sleep(2000); } @event.CancelEvents(); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "execute block as begin post_event 'test'; end"; cmd.ExecuteNonQuery(); Thread.Sleep(2000); } Assert.IsNull(exception); Assert.AreEqual(1, triggered); } }
public void DoubleQueueingTest() { using (var @event = new FbRemoteEvent(Connection.ConnectionString)) { @event.Open(); Assert.DoesNotThrow(() => @event.QueueEvents("test")); Assert.Throws <InvalidOperationException>(() => @event.QueueEvents("test")); } }
public void NoExceptionWithDispose() { var exception = (Exception)null; using (var @event = new FbRemoteEvent(Connection.ConnectionString)) { @event.RemoteEventError += (sender, e) => { exception = e.Error; }; @event.Open(); @event.QueueEvents("test"); Thread.Sleep(2000); } Thread.Sleep(2000); Assert.IsNull(exception); }
public void EventNameSeparateSelectionTest() { var exception = (Exception)null; var triggeredA = false; var triggeredB = false; using (var @event = new FbRemoteEvent(Connection.ConnectionString)) { @event.RemoteEventError += (sender, e) => { exception = e.Error; }; @event.RemoteEventCounts += (sender, e) => { switch (e.Name) { case "a": triggeredA = e.Counts == 1; break; case "b": triggeredB = e.Counts == 1; break; } }; @event.Open(); @event.QueueEvents("a", "b"); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "execute block as begin post_event 'b'; end"; cmd.ExecuteNonQuery(); cmd.CommandText = "execute block as begin post_event 'a'; end"; cmd.ExecuteNonQuery(); Thread.Sleep(2000); } Assert.IsNull(exception); Assert.IsTrue(triggeredA); Assert.IsTrue(triggeredB); } }
public void NoEventsAfterDispose() { var triggered = 0; using (var @event = new FbRemoteEvent(Connection.ConnectionString)) { @event.RemoteEventCounts += (sender, e) => { triggered++; }; @event.Open(); @event.QueueEvents("test"); Thread.Sleep(2000); } Thread.Sleep(2000); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "execute block as begin post_event 'test'; end"; cmd.ExecuteNonQuery(); Thread.Sleep(2000); } Assert.AreEqual(0, triggered); }