public async Task get_iotHub_update_device_twin() { DeviceTwinRepository repo = new DeviceTwinRepository(iotHubConnectionString); var tags = new DeviceTwinTagsModel() { ProductFamily = "ProductFamilyTest", ProductName = "ProductNameTest", RetailerName = "RetailerTest", ManufacturedDate = DateTime.Now, ShippedDate = DateTime.Now, RetailerRegion = "Chicago" }; var device = await repo.CreateAndInitializeDeviceTwin("unittestdevice", tags); Assert.Equal("unittestdevice", device.Id); // get device twin var deviceTwin = await repo.GetDeviceTwinAsync(device.Id); Assert.NotNull(deviceTwin); var deviceTwinModel = new DeviceTwinModel() { DeviceId = "unittestdevice", /*Location = new DeviceLocation() * { * AddressLine1 = "1100, S King Drive", * City = "Chicago", * State = "IL", * ZipCode = "50630", * Country = "US", * AdditionalNotes="Test Notes" * }, * Features = new List<DeviceFeature>() * { * new DeviceFeature(){ Name = "Just Test Feature", * Value = true } * * }, * ActivationDate = DateTime.Now, * ShipDate = DateTime.Now.AddDays(2)*/ }; //await repo.UpdateDeviceTwinTagsAsync(deviceTwinModel); await repo.InitializeDeviceTwinDesiredFeaturesAsync(new DeviceTwinDesiredFeaturesModel() { DeviceId = device.Id /*, ActivatedFeatures = deviceTwinModel.Features*/ }); // get device twin deviceTwin = await repo.GetDeviceTwinAsync(device.Id); //Assert.Equal(1,deviceTwin.Tags.Count); //Assert.True(deviceTwin.Tags.Contains("location")); //Assert.Equal(1, deviceTwin.Properties.Desired.Count); //Assert.True(deviceTwin.Properties.Desired.Contains("features")); }
public async Task create_iotHub_device() { DeviceTwinRepository repo = new DeviceTwinRepository(iotHubConnectionString); var tags = new DeviceTwinTagsModel() { ProductFamily = "ProductFamilyTest", ProductName = "ProductNameTest", RetailerName = "RetailerTest", ManufacturedDate = DateTime.Now, ShippedDate = DateTime.Now, RetailerRegion = "Chicago" }; var device = await repo.CreateAndInitializeDeviceTwin("unittestdevice", tags); Assert.Equal("unittestdevice", device.Id); }
public async Task get_iotHub_device_twin_list_groupby() { DeviceTwinRepository repo = new DeviceTwinRepository(iotHubConnectionString); var tags = new DeviceTwinTagsModel() { ProductFamily = "ProductFamilyTest", ProductName = "ProductNameTest", RetailerName = "RetailerTest", ManufacturedDate = DateTime.Now, ShippedDate = DateTime.Now, RetailerRegion = "Chicago" }; var device = await repo.CreateAndInitializeDeviceTwin("unittestdevice", tags); Assert.Equal("unittestdevice", device.Id); // get device twin // var devicesTwin = await repo.GetDevicesTwinGroupByAsync("retailerName"); // Assert.NotNull(deviceTwin); }