public void Should_consume_message_and_emit_payload()
        {
            var black = "#000000";

            string payload = $"{{ \"Color\": \"{black}\" }}";
            var    message = new MqttApplicationMessage {
                Payload = Encoding.UTF8.GetBytes(payload)
            };
            var eventArgs = new MqttApplicationMessageReceivedEventArgs("", message);
            var scheduler = new TestScheduler();

            MqttClientMock.SetupAllProperties();

            var subject = new MqttSource(Options, MqttClientMock.Object);

            scheduler.Schedule(TimeSpan.FromTicks(20), () =>
            {
                MqttClientMock.Object.ApplicationMessageReceivedHandler.HandleApplicationMessageReceivedAsync(eventArgs);
            });

            var actual = scheduler.Start(
                () => subject.Get(),
                created: 0,
                subscribed: 10,
                disposed: 100
                );

            var expected = new Recorded <Notification <object> >[] {
                OnNext(20, (object)payload)
            };

            ReactiveAssert.AreElementsEqual(expected, actual.Messages);
        }
        public void Should_consume_message_and_apply_transformations()
        {
            var   red           = "#ff0000";
            Color expectedColor = Color.FromArgb(255, 0, 255, 0);

            string payload = $"{{ \"Color\": \"{red}\" }}";
            var    message = new MqttApplicationMessage {
                Payload = Encoding.UTF8.GetBytes(payload)
            };
            var eventArgs = new MqttApplicationMessageReceivedEventArgs("", message);
            var scheduler = new TestScheduler();

            MqttClientMock.SetupAllProperties();

            Options.Transformations = new List <TransformationOptions>()
            {
                new JsonPathTransformationOptions()
                {
                    Expression = "$.Color"
                },
                new ColorTransformationOptions()
                {
                    ChannelLayout = "GRB"
                },
            }.ToArray();

            var subject = new MqttSource(Options, MqttClientMock.Object);

            scheduler.Schedule(TimeSpan.FromTicks(20), () =>
            {
                MqttClientMock.Object.ApplicationMessageReceivedHandler.HandleApplicationMessageReceivedAsync(eventArgs);
            });

            var actual = scheduler.Start(
                () => subject.Get(),
                created: 0,
                subscribed: 10,
                disposed: 100
                );

            var expected = new Recorded <Notification <object> >[] {
                OnNext(20, (object)new Ref <Color>(expectedColor))
            };

            ReactiveAssert.AreElementsEqual(expected, actual.Messages);
        }