public async Task RegisterAsyncOptionRemoveTest()
        {
            //arrange 
            var dbConnection = new UnitTestDbConnection();
            Database.SetInitializer(new CreateFreshDbInitializer());
            var dsb = new DeviceSettingBuilder(dbConnection);

            var deviceSetting = new DeviceSetting
            {
                Name = "Unit Test Device Setting",
                UniqueIdentifier = "DEVICE_SETTING1"
            };

            var option1 = new DeviceSettingOption
            {
                Name = "Option 1"
            };
            var option2 = new DeviceSettingOption
            {
                Name = "Option 2"
            };
            deviceSetting.Options.Add(option1);
            deviceSetting.Options.Add(option2);

            using (var context = new ZvsContext(dbConnection))
            {
                context.DeviceSettings.Add(deviceSetting);
                await context.SaveChangesAsync();
            }
            
            deviceSetting.Options.Remove(option2);

            //act
            var result = await dsb.RegisterAsync(deviceSetting, CancellationToken.None);

            DeviceSetting setting;
            using (var context = new ZvsContext(dbConnection))
            {
                setting = await context.DeviceSettings
                        .Include(o => o.Options)
                        .FirstOrDefaultAsync(o => o.UniqueIdentifier == deviceSetting.UniqueIdentifier);

            }

            //assert 
            Console.WriteLine(result.Message);
            Assert.IsFalse(result.HasError, result.Message);
            Assert.IsNotNull(setting, "Expected new device setting saved to DB");
            Assert.IsTrue(setting.Options.Count == 1, "Expected 1 option!");
            Assert.IsTrue(setting.Options[0].Name == option1.Name);
        }
        public async Task RegisterRemovedDeviceSettingOptionTest()
        {
            //Arrange 
            var dbConnection = new StubIEntityContextConnection { NameOrConnectionStringGet = () => "asb-RegisterRemovedDeviceSettingOptionTest" };
            Database.SetInitializer(new CreateFreshDbInitializer());

            var adapterBuilder = new AdapterSettingBuilder(dbConnection, CancellationToken.None);
            var deviceSetting = new DeviceSetting
            {
                Name = "Device Setting 1",
                ValueType = DataType.STRING,
                Value = "Hello World"
            };
            var option1 = new DeviceSettingOption
            {
                Name = "Option 1",
            };
            var option2 = new DeviceSettingOption
            {
                Name = "Option 2",
            };
            deviceSetting.Options.Add(option1);
            deviceSetting.Options.Add(option2);
            using (var context = new ZvsContext(dbConnection))
            {
                context.DeviceSettings.Add(deviceSetting);
                await context.SaveChangesAsync();
            }

            deviceSetting.Options.Remove(option2);

            //act
            var result = await adapterBuilder.RegisterDeviceSettingAsync(deviceSetting);

            DeviceSetting setting;
            using (var context = new ZvsContext(dbConnection))
            {
                setting = await context.DeviceSettings
                    .Include(o => o.Options)
                    .FirstOrDefaultAsync();
            }

            //assert 
            Console.WriteLine(result.Message);
            Assert.IsFalse(result.HasError);
            Assert.IsNotNull(setting, "Setting not found");
            Assert.IsTrue(setting.Options.Count == 1, "Expected 2 options");
            Assert.IsTrue(setting.Options[0].Name == option1.Name, "Name mismatch");
        }