public void ExampleSubscriberDoesGetNotified() { var subscriber = new ExampleSubscriber(); subscriber.Publisher.Name = "Thomas"; Assert.AreEqual("Thomas", subscriber.CurrentName); }
public async Task RoutingTestForClassSubscriber() { var address = "tcp://localhost:6000"; var publisherSocket = new PublisherSocket(); publisherSocket.Bind(address); var subscriberSocket = new SubscriberSocket(); subscriberSocket.Connect(address); var subscriber = new ExampleSubscriber(); var router = NetmqMessageRouter .WithPubSubConnecton(publisherSocket, subscriberSocket) .WithWorkerPool(numberOfSerializationWorkes: 2, numberOfHandlingWorkes: 8) .RegisterTypeSerializer(new RawDataTypeSerializer()) .RegisterTypeSerializer(new BasicTextTypeSerializer()) .RegisterGeneralSerializer(new JsonObjectSerializer()) .RegisterRoute("TestRoute", typeof(CustomPayload)) .RegisterSubscriber(subscriber) .StartRouting(); router.SendMessage("TestRoute", new CustomPayload("Hellow world", 123)); router.OnException += exception => { // handle any exception }; await Task.Delay(TimeSpan.FromSeconds(5)); router .StopRouting() .Disconnect(); var expectedValue = new CustomPayload("Hellow world", 123); Assert.AreEqual(expectedValue, subscriber.PassedValue); }