public async Task should_not_get_peer_with_non_matching_subscrition_binding_key() { _bus.AddHandler <RegisterPeerCommand>(x => new RegisterPeerResponse(new PeerDescriptor[0])); var command = new FakeRoutableCommand(10, "name"); var subscriptions = new[] { new Subscription(command.TypeId(), new BindingKey("5", "#")) }; await _directory.RegisterAsync(_bus, _self, subscriptions).ConfigureAwait(true); _directory.GetPeersHandlingMessage(command).ShouldBeEmpty(); }
public void should_send_routing_key_exception() { var msg = new FakeRoutableCommand(0, null); var exception = Assert.Throws <InvalidOperationException>(() => BindingKey.Create(msg)); exception.Message.ShouldContain(typeof(FakeRoutableCommand).Name); exception.Message.ShouldContain("Name"); exception.Message.ShouldContain("can not be null"); }
public void should_get_routing_key_from_message() { using (new CultureScope(CultureInfo.GetCultureInfo("FR-fr"))) { var message = new FakeRoutableCommand(42.42m, "name", Guid.NewGuid()); var rountingKey = BindingKey.Create(message); rountingKey.PartCount.ShouldEqual(3); rountingKey.GetPart(0).ShouldEqual("42.42"); rountingKey.GetPart(1).ShouldEqual("name"); rountingKey.GetPart(2).ShouldEqual(message.OtherId.ToString()); } }
public void should_get_peer_with_matching_subscrition_binding_key() { _bus.AddHandler <RegisterPeerCommand>(x => new RegisterPeerResponse(new PeerDescriptor[0])); var command = new FakeRoutableCommand(10, "name"); var subscriptions = new[] { new Subscription(command.TypeId(), new BindingKey("10", "#")) }; _directory.Register(_bus, _self, subscriptions); var peerHandlingMessage = _directory.GetPeersHandlingMessage(command).Single(); peerHandlingMessage.Id.ShouldEqual(_self.Id); }
public void should_filter_messages_using_predicate(decimal id, string name, bool shouldBeHandled) { // Arrange var bindingKey1 = new BindingKey("1", "toto", "*"); var bindingKey2 = new BindingKey("1", "titi", "*"); var handler = new DynamicMessageHandlerInvoker(_ => { }, typeof(FakeRoutableCommand), new[] { bindingKey1, bindingKey2 }); var message = new FakeRoutableCommand(id, name); // Act var handled = handler.ShouldHandle(message); // Assert handled.ShouldEqual(shouldBeHandled); }
public ExpectedResult(FakeRoutableCommand message, BindingKey bindingKey, bool result) { Message = message; BindingKey = bindingKey; Result = result; }