Example #1
0
        public void GetMessageBodyStringFromMessage_GivenUnCompressedBody_ReturnsJson()
        {
            //Arrange
            SpecificationVersionComparisonModel specificationVersionComparison = new SpecificationVersionComparisonModel()
            {
                Id      = "spec-1",
                Current = new Models.Messages.SpecificationVersion
                {
                    FundingPeriod = new Reference {
                        Id = "fp1"
                    },
                    Name = "any-name"
                },
                Previous = new Models.Messages.SpecificationVersion
                {
                    FundingPeriod = new Reference {
                        Id = "fp1"
                    }
                }
            };

            string json = JsonConvert.SerializeObject(specificationVersionComparison);

            byte[] messageBytes = Encoding.UTF8.GetBytes(json);

            Message message = new Message(messageBytes);

            //Act
            string result = MessageExtensions.GetMessageBodyStringFromMessage(message);

            //Assert
            result
            .Should()
            .BeEquivalentTo(json);
        }
Example #2
0
        public void GetMessageBodyStringFromMessage_GivenCompressedBody_ReturnsJson()
        {
            //Arrange
            Models.Specs.SpecificationVersionComparisonModel specificationVersionComparison = new Models.Specs.SpecificationVersionComparisonModel()
            {
                Id      = "spec-1",
                Current = new Models.Specs.SpecificationVersion
                {
                    FundingPeriod = new Reference {
                        Id = "fp1"
                    },
                    Name     = "any-name",
                    Policies = new[] { new Models.Specs.Policy {
                                           Id = "pol-id", Name = "policy2"
                                       } }
                },
                Previous = new Models.Specs.SpecificationVersion
                {
                    FundingPeriod = new Reference {
                        Id = "fp1"
                    },
                    Policies = new[] { new Models.Specs.Policy {
                                           Id = "pol-id", Name = "policy1"
                                       } }
                }
            };

            string json = JsonConvert.SerializeObject(specificationVersionComparison);

            byte[] messageBytes = json.Compress();

            Message message = new Message(messageBytes);

            message.UserProperties.Add("compressed", true);

            //Act
            string result = MessageExtensions.GetMessageBodyStringFromMessage(message);

            //Assert
            result
            .Should()
            .BeEquivalentTo(json);
        }