static void Main(string[] args) { var config = new JobHostConfiguration(); config.DashboardConnectionString = null; // apply config before creating the host. var cloudToDeviceExtension = new IoTHubExtension.Config.IoTCloudToDeviceExtension(); config.AddExtension(cloudToDeviceExtension); var directMethodExtension = new IoTHubExtension.Config.IoTDirectMethodExtension(); config.AddExtension(directMethodExtension); var setDeviceTwinExtension = new IoTHubExtension.Config.IoTSetDeviceTwinExtension(); config.AddExtension(setDeviceTwinExtension); var getDeviceTwinExtension = new IoTHubExtension.Config.IoTGetDeviceTwinExtension(); config.AddExtension(getDeviceTwinExtension); // Debug diagnostics! config.CreateMetadataProvider().DebugDumpGraph(Console.Out); var host = new JobHost(config); //Test some invocations. //var method = typeof(Functions).GetMethod("WriteMessageFromC2D"); //host.Call(method); var method = typeof(Functions).GetMethod("WriteMessageFromC2DArg"); host.Call(method, new { deviceId = "receiverBob" }); //Test some invocations. method = typeof(Functions).GetMethod("DirectInvokeMethod"); host.Call(method, new { deviceId = "receiverAlice" }); //// Test some invocations. method = typeof(Functions).GetMethod("SetDeviceTwin"); host.Call(method, new { deviceId = "receiverBob" }); //// Test some invocations. method = typeof(Functions).GetMethod("GetDeviceTwinTwinObject"); host.Call(method, new { deviceId = "receiverBob", messageId = "123" }); }
public void DefaultTypeForQueue() { JobHostConfiguration config = TestHelpers.NewConfig(); var tooling = config.CreateMetadataProvider(); var t1 = tooling.GetDefaultType(new QueueAttribute("q"), FileAccess.Read, typeof(byte[])); Assert.Equal(typeof(byte[]), t1); var t2 = tooling.GetDefaultType(new QueueAttribute("q"), FileAccess.Read, null); Assert.Equal(typeof(string), t2); var t3 = tooling.GetDefaultType(new QueueAttribute("q"), FileAccess.Write, null); Assert.Equal(typeof(IAsyncCollector <byte[]>), t3); }
public void DefaultTypeForTable() { JobHostConfiguration config = TestHelpers.NewConfig(); var tooling = config.CreateMetadataProvider(); var t1 = tooling.GetDefaultType(new TableAttribute("table1"), FileAccess.Read, null); Assert.Equal(typeof(JArray), t1); var t2 = tooling.GetDefaultType(new TableAttribute("table1", "pk", "rk"), FileAccess.Read, null); Assert.Equal(typeof(JObject), t2); var t3 = tooling.GetDefaultType(new TableAttribute("table1"), FileAccess.Write, null); Assert.Equal(typeof(IAsyncCollector <JObject>), t3); }
public void AttrBuilder() { JobHostConfiguration config = TestHelpers.NewConfig(); var tooling = config.CreateMetadataProvider(); // Blob var blobAttr = GetAttr <BlobAttribute>(tooling, new { path = "x" }); Assert.Equal("x", blobAttr.BlobPath); Assert.Equal(null, blobAttr.Access); blobAttr = GetAttr <BlobAttribute>(tooling, new { path = "x", direction = "in" }); Assert.Equal("x", blobAttr.BlobPath); Assert.Equal(FileAccess.Read, blobAttr.Access); blobAttr = GetAttr <BlobAttribute>(tooling, new { Path = "x", Direction = "out" }); Assert.Equal("x", blobAttr.BlobPath); Assert.Equal(FileAccess.Write, blobAttr.Access); blobAttr = GetAttr <BlobAttribute>(tooling, new { path = "x", direction = "inout" }); Assert.Equal("x", blobAttr.BlobPath); Assert.Equal(FileAccess.ReadWrite, blobAttr.Access); blobAttr = GetAttr <BlobAttribute>(tooling, new { path = "x", direction = "in", connection = "cx1" }); Assert.Equal("x", blobAttr.BlobPath); Assert.Equal(FileAccess.Read, blobAttr.Access); Assert.Equal("cx1", blobAttr.Connection); blobAttr = GetAttr <BlobAttribute>(tooling, new { path = "x", direction = "in", connection = "" // empty, not null }); Assert.Equal("x", blobAttr.BlobPath); Assert.Equal(FileAccess.Read, blobAttr.Access); Assert.Equal("", blobAttr.Connection); // empty is passed straight through. var blobTriggerAttr = GetAttr <BlobTriggerAttribute>(tooling, new { path = "x" }); Assert.Equal("x", blobTriggerAttr.BlobPath); // Queue var queueAttr = GetAttr <QueueAttribute>(tooling, new { QueueName = "q1" }); Assert.Equal("q1", queueAttr.QueueName); var queueTriggerAttr = GetAttr <QueueTriggerAttribute>(tooling, new { QueueName = "q1" }); Assert.Equal("q1", queueTriggerAttr.QueueName); // Table var tableAttr = GetAttr <TableAttribute>(tooling, new { TableName = "t1" }); Assert.Equal("t1", tableAttr.TableName); tableAttr = GetAttr <TableAttribute>(tooling, new { TableName = "t1", partitionKey = "pk", Filter = "f1" }); Assert.Equal("t1", tableAttr.TableName); Assert.Equal("pk", tableAttr.PartitionKey); Assert.Equal(null, tableAttr.RowKey); Assert.Equal("f1", tableAttr.Filter); }