Пример #1
0
        public async Task CancelTest()
        {
            var exception = (Exception)null;
            var triggered = 0;

            await using (var @event = new FbRemoteEvent(Connection.ConnectionString))
            {
                @event.RemoteEventError += (sender, e) =>
                {
                    exception = e.Error;
                };
                @event.RemoteEventCounts += (sender, e) =>
                {
                    triggered++;
                };
                await @event.OpenAsync();

                await @event.QueueEventsAsync(new[] { "test" });

                await using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "execute block as begin post_event 'test'; end";
                    await cmd.ExecuteNonQueryAsync();

                    Thread.Sleep(2000);
                }
                await @event.CancelEventsAsync();

                await using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "execute block as begin post_event 'test'; end";
                    await cmd.ExecuteNonQueryAsync();

                    Thread.Sleep(2000);
                }
                Assert.IsNull(exception);
                Assert.AreEqual(1, triggered);
            }
        }