public void CreateVariant() { var property = GetTestProperty(out PropertyVariationOption[] variations); var vm = new CreateVariantViewModel(property.Object); Assume.That(vm.Variation, Is.Null); bool changed = false; vm.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(CreateVariantViewModel.Variation)) { changed = true; } }; vm.VariationCategories[0].SelectedOption = vm.VariationCategories[0].Variations[1]; vm.VariationCategories[1].SelectedOption = vm.VariationCategories[1].Variations[2]; vm.CreateVariantCommand.Execute(null); Assert.That(changed, Is.True, "Variation did not fire PropertyChanged"); Assert.That(vm.Variation, Is.Not.Null); Assert.That(vm.Variation.Count, Is.EqualTo(2)); Assert.That(vm.Variation, Contains.Item(vm.VariationCategories[0].Variations[1])); Assert.That(vm.Variation, Contains.Item(vm.VariationCategories[1].Variations[2])); }
public void VariantCategories() { var property = GetTestProperty(out PropertyVariationOption[] variations); var categories = variations.Select(v => v.Category).Distinct().ToArray(); var vm = new CreateVariantViewModel(property.Object); Assert.That(vm.VariationCategories.Count, Is.EqualTo(categories.Length)); CollectionAssert.AreEqual(vm.VariationCategories.Select(v => v.Name), categories); }
public void WhenAllAnyCommandDisabledEnabled() { var property = GetTestProperty(out PropertyVariationOption[] variations); var vm = new CreateVariantViewModel(property.Object); Assume.That(vm.VariationCategories.All(vvm => vvm.IsAnySelected), Is.True); Assert.That(vm.CreateVariantCommand.CanExecute(null), Is.False); bool changed = false; vm.CreateVariantCommand.CanExecuteChanged += (sender, args) => changed = true; vm.VariationCategories[0].SelectedOption = vm.VariationCategories[0].Variations[1]; Assert.That(changed, Is.True, "CanExecuteChanged did not fire"); Assert.That(vm.CreateVariantCommand.CanExecute(null), Is.True); }
public CreateVariantWindow(IEnumerable <ResourceDictionary> merged, IPropertyInfo property) { DataContext = new CreateVariantViewModel(property); InitializeComponent(); Resources.MergedDictionaries.AddItems(merged); }