static void Main(string[] args) { "Testing AbstractCommunicator".Title(); TestCommunicator tc1 = new TestCommunicator(); tc1.Name = "tc1"; tc1.Start(); TestCommunicator tc2 = new TestCommunicator(); tc2.Name = "tc2"; tc2.Start(); TestDispatcher td = new TestDispatcher(); td.Name = "td"; td.Verbose = true; td.Start(); td.Register(tc1); // show that GetInstance works AbstractMessageDispatcher tdi = TestDispatcher.GetInstance(); tdi.Register(tc2); ServiceMessage msg0 = ServiceMessage.MakeMessage("foobar", "Main", "going nowhere"); td.PostMessage(msg0); ServiceMessage msg1 = ServiceMessage.MakeMessage(tc1.Name, "Main", "some boring contents"); td.PostMessage(msg1); ServiceMessage msg2 = ServiceMessage.MakeMessage(tc2.Name, "Main", "more boring contents"); td.PostMessage(msg2); ServiceMessage msg3 = ServiceMessage.MakeMessage(tc1.Name, "Main", "quit"); td.PostMessage(msg3); ServiceMessage msg4 = ServiceMessage.MakeMessage(tc2.Name, "Main", "quit"); td.PostMessage(msg4); ServiceMessage msg5 = ServiceMessage.MakeMessage(td.Name, "Main", "quit"); td.PostMessage(msg5); tc1.Wait(); tc2.Wait(); td.Wait(); Console.Write("\n\n"); }
public async Task Simple_test_sync() { TestSyncFeed syncFeed = new TestSyncFeed(); TestDispatcher dispatcher = new TestDispatcher(syncFeed, new TestSyncPeerPool(), new StaticPeerAllocationStrategyFactory <TestBatch>(FirstFree.Instance)); Task executorTask = dispatcher.Start(CancellationToken.None); syncFeed.Activate(); await executorTask; for (int i = 0; i < TestSyncFeed.Max; i++) { syncFeed._results.Contains(i).Should().BeTrue(i.ToString()); } }