Esempio n. 1
0
        public async Task SendsMessageDataAsPayload()
        {
            var capture   = new SendCapture();
            var connector = GetConnector(capture);

            var(connectionRegistry, identityProvider) = GetHandlerDependencies();
            var identity = new DeviceIdentity("hub", "device_id");
            var method   = new DirectMethodRequest("12345", "method", new byte[] { 1, 2, 3 }, TimeSpan.FromSeconds(5));

            var sut = new DirectMethodHandler(connectionRegistry, identityProvider);

            sut.SetConnector(connector);

            await sut.CallDirectMethodAsync(method, identity, true);

            Assert.Equal(new byte[] { 1, 2, 3 }, capture.Content);
        }
Esempio n. 2
0
        public async Task EncodesDeviceNameInTopic()
        {
            var capture   = new SendCapture();
            var connector = GetConnector(capture);

            var(connectionRegistry, identityProvider) = GetHandlerDependencies();
            var identity = new DeviceIdentity("hub", "device_id");
            var method   = new DirectMethodRequest("12345", "method", new byte[] { 1, 2, 3 }, TimeSpan.FromSeconds(5));

            var sut = new DirectMethodHandler(connectionRegistry, identityProvider);

            sut.SetConnector(connector);

            await sut.CallDirectMethodAsync(method, identity, true);

            Assert.Equal("$edgehub/device_id/methods/post/method/?$rid=" + method.CorrelationId, capture.Topic);
        }