public void Test5() { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var pubsub = new PublishBuffer <int>(loggerFactory, "test"); Console.WriteLine("Start"); pubsub.Subscribe(HandlerASync); try { pubsub.Subscribe(HandlerASync); Assert.Fail("Expect exception"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void Test1() { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var pubsub = new PublishBuffer <int>(loggerFactory, "test"); Console.WriteLine("Start"); pubsub.Subscribe(Handler); pubsub.Put(1); pubsub.Put(2); pubsub.Put(3); Thread.Sleep(2000); pubsub.UnSubscribe(); Thread.Sleep(2000); Console.WriteLine("Done"); }
public void Test6() { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var pubsub = new PublishBuffer <int>(loggerFactory, "test"); Console.WriteLine("Start"); pubsub.Subscribe(Handler); Thread.Sleep(1000); Console.WriteLine("put 1, 2"); pubsub.PutRange(new [] { 1, 2 }); Console.WriteLine("put 3, 4"); pubsub.PutRange(new[] { 3, 4 }); Console.WriteLine("UnSubscribe"); pubsub.UnSubscribe(); Console.WriteLine("Done"); }
static void Main(string[] args) { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var pubsub = new PublishBuffer <int>(loggerFactory, "test"); var token = new CancellationTokenSource(); Console.WriteLine("Start"); pubsub.Subscribe(Handler, token.Token); Thread.Sleep(2000); pubsub.Put(1); token.Cancel(); Thread.Sleep(2000); Console.WriteLine("Press enter ..."); Console.ReadLine(); Console.WriteLine("Done"); pubsub.Dispose(); }
public void Test_Subscriber_Call_ASync() { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var pubsub = new PublishBuffer <int>(loggerFactory, "test"); Console.WriteLine("Start"); pubsub.Subscribe(HandlerDelayASync); Thread.Sleep(1000); Console.WriteLine("put 1"); pubsub.Put(1); Console.WriteLine("put 2"); pubsub.Put(2); Console.WriteLine("put 3"); pubsub.Put(3); Thread.Sleep(3000); pubsub.UnSubscribe(); Thread.Sleep(3000); Console.WriteLine("Done"); }
public void Test7() { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var pubsub = new PublishBuffer <int>(loggerFactory, "test"); Console.WriteLine("Start"); pubsub.Subscribe(HandlerASync); Thread.Sleep(1000); pubsub.PutRange(new [] { 1, 2 }); pubsub.UnSubscribe(); try { pubsub.PutRange(new[] { 3, 4 }); Assert.Fail("Expect exception"); } catch (Exception e) { Console.WriteLine(e.Message); } }