Ejemplo n.º 1
0
        public void Test_ServiceBus_MessageEntity()
        {
            // Arrange
            var entity = new MessageEntity <TestObject>
            {
                Body = new TestObject
                {
                    Prop1 = "test"
                },
                Properties = new Dictionary <string, object>
                {
                    { "Prop1", "PropTest" }
                }
            };

            // Act
            var propEntity = entity.GetPropertiesTyped <TestObject>();

            // Assert
            entity.Body.Prop1.Should().BeEquivalentTo("test");
            propEntity.Prop1.Should().BeEquivalentTo("PropTest");
        }
        public void Test_MessageEntity_ToFromJson()
        {
            // Arrage
            var wrapper = new MessageEntity <string>("body", new KeyValuePair <string, object>[1]
            {
                new KeyValuePair <string, object>("Key", "value")
            });

            // Act
            var jsonVersion = wrapper.AsJson();
            var converted   = JsonConvert.DeserializeObject <MessageEntity <string> >(jsonVersion);
            var typedProps  = wrapper.GetPropertiesTyped <TypedPropsSample>();

            // Assert
            converted.Body.Should().Be("body");
            converted.Properties.Should().BeEquivalentTo(new KeyValuePair <string, object>[1]
            {
                new KeyValuePair <string, object>("Key", "value")
            });
            typedProps.Should().NotBeNull();
            typedProps.Key.Should().Be("value");
        }