public void when_get_attribute() { var immutableEnvelope = new ImmutableEnvelope("id", DateTime.UtcNow, new object(), new[] { new MessageAttribute("attr1", "val1"), }); var attributeVal = immutableEnvelope.GetAttribute("attr1"); Assert.AreEqual("val1", attributeVal); }
public void when_attribute_not_contains_and_get_default_value() { var immutableEnvelope = new ImmutableEnvelope("id", DateTime.UtcNow, new object(), new[] { new MessageAttribute("attr1", "val1"), }); var attributeVal = immutableEnvelope.GetAttribute("attr2", "default"); Assert.AreEqual("default", attributeVal); }
public void DispatchMessage(ImmutableEnvelope message) { var entity = message.GetAttribute("to-entity", ""); if (string.IsNullOrEmpty(entity)) { throw new InvalidOperationException("Message without entity address arrived to this dispatcher"); } var commands = message.Items.Select(i => (ICommand)i.Content); Dispatch(entity, commands); }