From 2705938c873ad2227274dfba480f13883bf46adb Mon Sep 17 00:00:00 2001 From: Varun Puranik Date: Wed, 22 Aug 2018 18:13:54 -0700 Subject: [PATCH] Add test and change name --- e2e/test/IoTHubServiceProxyE2ETests.cs | 23 ++++++++++++++++++++++- iothub/service/src/Device.cs | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/e2e/test/IoTHubServiceProxyE2ETests.cs b/e2e/test/IoTHubServiceProxyE2ETests.cs index f4b6a18796..d6e7753823 100644 --- a/e2e/test/IoTHubServiceProxyE2ETests.cs +++ b/e2e/test/IoTHubServiceProxyE2ETests.cs @@ -46,6 +46,27 @@ public async Task RegistryManager_AddAndRemoveDevice_WithProxy() await RegistryManager_AddDevice(httpTransportSettings).ConfigureAwait(false); } + [TestMethod] + public async Task RegistryManager_AddAndRemoveDeviceWithScope() + { + RegistryManager registryManager = RegistryManager.CreateFromConnectionString(ConnectionString); + + var edgeDevice = new Device(Guid.NewGuid().ToString()) + { + Capabilities = new DeviceCapabilities { IotEdge = true } + }; + edgeDevice = await registryManager.AddDeviceAsync(edgeDevice).ConfigureAwait(false); + + var leafDevice = new Device(Guid.NewGuid().ToString()) { Scope = edgeDevice.Scope }; + Device receivedDevice = await registryManager.AddDeviceAsync(leafDevice).ConfigureAwait(false); + + Assert.IsNotNull(receivedDevice); + Assert.AreEqual(leafDevice.Id, receivedDevice.Id); + Assert.AreEqual(leafDevice.Scope, receivedDevice.Scope); + await registryManager.RemoveDeviceAsync(leafDevice.Id).ConfigureAwait(false); + await registryManager.RemoveDeviceAsync(edgeDevice.Id).ConfigureAwait(false); + } + [TestMethod] public async Task JobClient_ScheduleAndRunTwinJob_WithProxy() { @@ -91,7 +112,7 @@ private async Task JobClient_ScheduleAndRunTwinJob(HttpTransportSettings httpTra JobResponse jobResponse = await jobClient.GetJobAsync(jobId).ConfigureAwait(false); } - private Message ComposeD2CTestMessage(out string payload, out string p1Value) + private Message ComposeD2CTestMessage(out string payload, out string p1Value) { payload = Guid.NewGuid().ToString(); p1Value = Guid.NewGuid().ToString(); diff --git a/iothub/service/src/Device.cs b/iothub/service/src/Device.cs index 6190c822e9..a2506a91cb 100644 --- a/iothub/service/src/Device.cs +++ b/iothub/service/src/Device.cs @@ -112,7 +112,7 @@ public string ETag /// /// Scope to which this device instance belongs to /// - [JsonProperty(PropertyName = "securityScope", NullValueHandling = NullValueHandling.Ignore)] - public virtual string SecurityScope { get; set; } + [JsonProperty(PropertyName = "deviceScope", NullValueHandling = NullValueHandling.Ignore)] + public virtual string Scope { get; set; } } }