public void TestInboundStreamInterestReplaceAttribute() { var inboundStreamInterest = TestWorld.ActorFor <IInboundStreamInterest>( Definition.Has <AttributesAgentActor>( Definition.Parameters(_localNode, Application, _outboundStream.Actor, Config, _interest))); var addMessage = AddAttribute.From(_localNode, _set, _tracked); inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, addMessage)); var replaceMessage = ReplaceAttribute.From(_localNode, _set, _tracked); inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, replaceMessage)); var channel1 = _channelProvider.ChannelFor(_localNodeId); Assert.Equal(2, Mock(channel1).Writes.Count); Assert.Equal(1, Application.InformAttributeAddedCheck.Get()); Assert.Equal(1, Application.InformAttributeReplacedCheck.Get()); }
internal void DistributeTo( AttributeSet set, TrackedAttribute tracked, ApplicationMessageType type, IEnumerable <Node> nodes) { switch (type) { case ApplicationMessageType.AddAttribute: var add = AddAttribute.From(_node, set, tracked); var addConfirmable = _confirmables.UnconfirmedFor(add, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, add.ToPayload()), addConfirmable.UnconfirmedNodes); _application.InformAttributeAdded(set.Name !, tracked.Attribute?.Name); break; case ApplicationMessageType.RemoveAttribute: var remove = RemoveAttribute.From(_node, set, tracked); var removeConfirmable = _confirmables.UnconfirmedFor(remove, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, remove.ToPayload()), removeConfirmable.UnconfirmedNodes); _application.InformAttributeRemoved(set.Name !, tracked.Attribute?.Name); break; case ApplicationMessageType.RemoveAttributeSet: var removeSet = RemoveAttributeSet.From(_node, set); var removeSetConfirmable = _confirmables.UnconfirmedFor(removeSet, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, removeSet.ToPayload()), removeSetConfirmable.UnconfirmedNodes); _application.InformAttributeSetRemoved(set.Name); break; case ApplicationMessageType.ReplaceAttribute: var replace = ReplaceAttribute.From(_node, set, tracked); var replaceConfirmable = _confirmables.UnconfirmedFor(replace, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, replace.ToPayload()), replaceConfirmable.UnconfirmedNodes); _application.InformAttributeReplaced(set.Name !, tracked.Attribute?.Name); break; default: throw new InvalidOperationException("Cannot distribute unknown ApplicationMessageType."); } }