public void TestMessageSizeDoesNotExceedsLimit()
        {
            var maxMessageSize = Int32.Parse(Twin.GetConfiguration("maxMessageSizeInBytes"));

            Twin.ChangeEventPriority(typeof(FakeOperationalEvent).Name, EventPriority.High)
            .ChangeEventPriority(typeof(FakePeriodicEvent).Name, EventPriority.High)
            .ChangeEventPriority(typeof(FakeTriggeredEvent).Name, EventPriority.High)
            .UpdateAgentTwinConfiguration();

            var expectedOperationalEvent = FakesEventsFactory.CreateFakeOperationalEvent();
            var expectedPeriodicEvent    = FakesEventsFactory.CreateFakePeriodicEvent(EventPriority.High);
            var expectedTriggeredEvent   = FakesEventsFactory.CreateFakeTriggeredEvent(EventPriority.High);

            FakeOperationalEventGenerator.SetEvents(new[] { expectedOperationalEvent });
            FakeSnapshotEventGenerator.SetEvents(new[] { expectedPeriodicEvent });
            FakeTriggeredEventGenerator.SetEvents(new[] { expectedTriggeredEvent });

            RepeatAction(_eventProducer, 100);
            RepeatAction(_messageBuilderConsumer, 100);

            Assert.IsTrue(MessageHelper.WaitUntilAsyncMessageSendsComplete(ClientMock));

            var sentMessages = ClientMock.GetMessages();

            Assert.IsTrue(sentMessages.Count > 0);

            foreach (var msg in sentMessages)
            {
                Assert.IsTrue(msg.GetBytes().Length < maxMessageSize);
            }
        }
        public void TestEventNotFiredIfEventIsTooBig()
        {
            var maxMessageSize = Int32.Parse(Twin.GetConfiguration("maxMessageSizeInBytes"));

            Twin.ChangeEventPriority(typeof(FakeOperationalEvent).Name, EventPriority.High)
            .UpdateAgentTwinConfiguration();
            Assert.AreEqual((uint)maxMessageSize, AgentConfiguration.RemoteConfiguration.MaxMessageSize);

            var expectedEvent = FakesEventsFactory.CreateFakeOperationalEvent(GenerateBigFakePayload(maxMessageSize));

            FakeOperationalEventGenerator.SetEvents(new[] { expectedEvent });

            RepeatAction(_eventProducer, 100);

            _messageBuilderConsumer.ExecuteTask();
            var sentMessages = ClientMock.GetMessages();

            Assert.AreEqual(0, sentMessages.Count);
        }