public void DistributedPubSubMediator_should_get_topics_after_simple_publish() { DistributedPubSubMediator_should_receive_proper_UnsubscribeAck_message(); Within(TimeSpan.FromSeconds(15), () => { RunOn(() => { var s1 = new Distributed.Subscribe("topic_a1", CreateChatUser("u14")); Mediator.Tell(s1); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s1)); var s2 = new Distributed.Subscribe("topic_a1", CreateChatUser("u15")); Mediator.Tell(s2); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s2)); var s3 = new Distributed.Subscribe("topic_a2", CreateChatUser("u16")); Mediator.Tell(s3); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s3)); }, _first); RunOn(() => { var s3 = new Distributed.Subscribe("topic_a1", CreateChatUser("u17")); Mediator.Tell(s3); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s3)); }, _second); EnterBarrier("topics-registered"); RunOn(() => { Mediator.Tell(Distributed.GetTopics.Instance); ExpectMsg <Distributed.CurrentTopics>( x => x.Topics.Contains("topic_a1") && x.Topics.Contains("topic_a2")); }, _first); RunOn(() => { // topics will eventually be replicated AwaitAssert(() => { Mediator.Tell(Distributed.GetTopics.Instance); var topics = ExpectMsg <Distributed.CurrentTopics>().Topics; Assert.True(topics.Contains("topic_a1")); Assert.True(topics.Contains("topic_a2")); }); }, _second); EnterBarrier("after-get-topics"); }); }
//[MultiNodeFact(Skip = "TODO")] public void DistributedPubSubMediator_should_publish_to_topic() { DistributedPubSubMediator_should_publish(); Within(TimeSpan.FromSeconds(15), () => { RunOn(() => { var s8 = new Distributed.Subscribe("topic1", CreateChatUser("u8")); Mediator.Tell(s8); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s8)); var s9 = new Distributed.Subscribe("topic1", CreateChatUser("u9")); Mediator.Tell(s9); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s9)); }, _first); RunOn(() => { var s10 = new Distributed.Subscribe("topic1", CreateChatUser("u10")); Mediator.Tell(s10); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s10)); }, _second); // one topic on two nodes AwaitCount(8); EnterBarrier("topic1-registered"); RunOn(() => { ChatUser("u5").Tell(new Shout("topic1", "hello all")); }, _third); RunOn(() => { var names = ReceiveWhile(x => "hello all".Equals(x) ? LastSender.Path.Name : null, msgs: 2); Assert.True(names.All(x => x == "u8" || x == "u9")); }, _first); RunOn(() => { ExpectMsg("hello all"); Assert.Equal("u10", LastSender.Path.Name); }, _second); RunOn(() => { ExpectNoMsg(TimeSpan.FromSeconds(2)); }, _third); EnterBarrier("after-7"); }); }
//[MultiNodeFact(Skip = "TODO")] public void DistributedPubSubMediator_should_receive_proper_UnsubscribeAck_message() { DistributedPubSubMediator_should_remove_entries_when_node_is_removed(); Within(TimeSpan.FromSeconds(15), () => { RunOn(() => { var user = CreateChatUser("u111"); var topic = "sample-topic-14"; var s1 = new Distributed.Subscribe(topic, user); Mediator.Tell(s1); ExpectMsg <Distributed.SubscribeAck>(x => x.Subscribe.Equals(s1)); var uns = new Distributed.Unsubscribe(topic, user); Mediator.Tell(uns); ExpectMsg <Distributed.UnsubscribeAck>(x => x.Unsubscribe.Equals(uns)); }, _first); EnterBarrier("after-15"); }); }