public void Serializes_And_Deserializes_Messages()
        {
            var targets = new Address[] { new Address(new byte[] { 10, 20, 127, 54, 51 }), null };
            var type    = "NotARealActionType";
            var payload = new Dictionary <string, object>()
            {
                { "isTest", true },
            };

            var serializedMessage = StrongForceSerialization.SerializeMessage(targets, type, payload);

            var deserializedMessage = StrongForceSerialization.DeserializeMessage(serializedMessage);

            Assert.Equal(targets, deserializedMessage.Item1);
            Assert.Equal(type, deserializedMessage.Item2);
            Assert.Equal(payload, deserializedMessage.Item3);
        }
Пример #2
0
            public (Address Sender, Address[] Targets, string Type, IDictionary <string, object> Payload) ReadMessage()
            {
                var message = this.ReadFromStream();

                if (message.Action == null)
                {
                    throw new InvalidOperationException("Expected an Action message");
                }

                var sender = new Address(message.Action.Address.ToByteArray());

                var data = message.Action.Data.ToByteArray();

                this.integration.logger.LogTrace("Received message data: " + data.Length + " bytes from " + sender);

                var(targets, messageType, messagePayload) = StrongForceSerialization.DeserializeMessage(data);
                this.integration.logger.LogInformation("Received an action with type: " + messageType);

                return(sender, targets, messageType, messagePayload);
            }