Пример #1
0
        public async Task Should_apply_a_static_effect()
        {
            var color  = Color.FromArgb(139, 0, 0);
            var bgr    = 139;
            var device = "mouse";

            var content = ToStringContent(JsonConvert.SerializeObject(new ChromaEffect()
            {
                Param = new Dictionary <string, int>()
                {
                    { "color", bgr }
                }
            }));


            var subject = new ChromaClient(HttpClient)
            {
                SessionUri = SESSION_URI
            };

            ExpectRequest(HttpMethod.Put, $"{SESSION_URI}/{device}", content);
            await subject.ApplyStaticEffectAsync(device, color);

            Handler.Verify();
        }
Пример #2
0
        public void Should_throw_exception_when_apply_static_effect_returns_non_zero_exit_code()
        {
            var color  = Color.FromArgb(139, 0, 0);
            var bgr    = 139;
            var device = "mouse";

            var content = ToStringContent(JsonConvert.SerializeObject(new ChromaEffect()
            {
                Param = new Dictionary <string, int>()
                {
                    { "color", bgr }
                }
            }));

            var subject = new ChromaClient(HttpClient)
            {
                SessionUri = SESSION_URI
            };

            ExpectRequest(HttpMethod.Put, $"{SESSION_URI}/{device}", content, @"{""result"": 76, ""error"": ""failed big times""}");

            Assert.ThrowsAsync <ChromaException>(() => subject.ApplyStaticEffectAsync(device, color));
            Handler.Verify();
        }
Пример #3
0
        public void Should_throw_exception_on_request_failure_to_apply_static_effect()
        {
            var color  = Color.FromArgb(139, 0, 0);
            var bgr    = 139;
            var device = "mouse";

            var content = ToStringContent(JsonConvert.SerializeObject(new ChromaEffect()
            {
                Param = new Dictionary <string, int>()
                {
                    { "color", bgr }
                }
            }));

            var subject = new ChromaClient(HttpClient)
            {
                SessionUri = SESSION_URI
            };

            ExpectRequest(HttpMethod.Put, $"{SESSION_URI}/{device}", content, @"{""result"": 76}", HttpStatusCode.InternalServerError);

            Assert.ThrowsAsync <HttpRequestException>(() => subject.ApplyStaticEffectAsync(device, color));
            Handler.Verify();
        }