Exemplo n.º 1
0
        public void EditorAllFormattersPropSave()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);
            AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);
            AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 3, _typesContainer);
            AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 4, _typesContainer);
            AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 5, _typesContainer);
            AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 6, _typesContainer);

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            Assert.AreEqual(result.RootConfigurationItemList.Count, 1);

            var itemList = (result.RootConfigurationItemList[0] as DefaultItemsGroup).ConfigurationItemList;

            CheckPropertyResultProperty(itemList, 1);
            CheckPropertyResultProperty(itemList, 2);
            CheckPropertyResultProperty(itemList, 3);
            CheckPropertyResultProperty(itemList, 4);
            CheckPropertyResultProperty(itemList, 5);
            CheckPropertyResultProperty(itemList, 6);

            Assert.AreEqual(itemList.Count, 6);
        }
Exemplo n.º 2
0
        public void ValidateEditorPropertySharedResourceRegexWithResourceIsNotString()
        {
            IResultingDeviceViewModel initialDevice = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>();

            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var deviceSharedResources = new DeviceSharedResources();
            ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel =
                _typesContainer.Resolve <ISharedResourcesGlobalViewModel>();

            sharedResourcesGlobalViewModel.InitializeFromResources(deviceSharedResources);

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var property = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);

            property.FormatterParametersViewModel.RelatedUshortsFormatterViewModel = new BoolFormatterViewModel();
            property.Name = "Pupa";

            configurationEditorViewModel.SelectedRow = property;

            sharedResourcesGlobalViewModel.AddAsSharedResourceWithContainer(property, null, false);

            property.Parent = rootGroup;


            var property2 = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);

            property2.DependencyViewModels.Add(
                new ConditionResultDependencyViewModel(new List <IResultViewModel>(), new List <IConditionViewModel>())
            {
                SelectedConditionViewModel = new RegexMatchConditionViewModel(
                    _typesContainer.Resolve <ISharedResourcesGlobalViewModel>())
                {
                    ReferencedResourcePropertyName = "Pupa"
                }
            });



            initialDevice.FragmentEditorViewModels
            .Add(configurationEditorViewModel);

            var res = _typesContainer.Resolve <IDeviceEditorViewModelValidator>()
                      .ValidateDeviceEditor(new List <IFragmentEditorViewModel>()
            {
                configurationEditorViewModel
            });

            Assert.True(res.Count == 1);
        }
Exemplo n.º 3
0
        public void EditorAllFormattersPropCopySave()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            var original1        = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);
            var original2        = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);
            var original3        = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 3, _typesContainer);
            var original4        = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 4, _typesContainer);
            var original5        = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 5, _typesContainer);
            var original6        = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 6, _typesContainer);
            var originalFromBits = AddPropertyWithBitsViewModel(rootGroup.ChildStructItemViewModels, 6, _typesContainer);



            rootGroup.ChildStructItemViewModels.Add(original1.Clone() as IConfigurationItemViewModel);
            rootGroup.ChildStructItemViewModels.Add(original2.Clone() as IConfigurationItemViewModel);
            rootGroup.ChildStructItemViewModels.Add(original3.Clone() as IConfigurationItemViewModel);
            rootGroup.ChildStructItemViewModels.Add(original4.Clone() as IConfigurationItemViewModel);
            rootGroup.ChildStructItemViewModels.Add(original5.Clone() as IConfigurationItemViewModel);
            rootGroup.ChildStructItemViewModels.Add(original6.Clone() as IConfigurationItemViewModel);
            rootGroup.ChildStructItemViewModels.Add(originalFromBits.Clone() as IConfigurationItemViewModel);


            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            Assert.AreEqual(result.RootConfigurationItemList.Count, 1);

            var itemList = (result.RootConfigurationItemList[0] as DefaultItemsGroup).ConfigurationItemList;

            Assert.AreEqual(itemList.Count, 14);

            CheckPropertyResultProperty(itemList, 1);
            CheckPropertyResultProperty(itemList, 2);
            CheckPropertyResultProperty(itemList, 3);
            CheckPropertyResultProperty(itemList, 4);
            CheckPropertyResultProperty(itemList, 5);
            CheckPropertyResultProperty(itemList, 6);
            CheckPropertyFromBitsResultProperty(itemList, 6, 7);

            var copiesList = itemList.Skip(7).Take(7).ToList();

            CheckPropertyResultProperty(copiesList, 1);
            CheckPropertyResultProperty(copiesList, 2);
            CheckPropertyResultProperty(copiesList, 3);
            CheckPropertyResultProperty(copiesList, 4);
            CheckPropertyResultProperty(copiesList, 5);
            CheckPropertyResultProperty(copiesList, 6);
            CheckPropertyFromBitsResultProperty(copiesList, 6, 7);
        }
Exemplo n.º 4
0
        public void EditorCopyPropAsSharedResources()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var deviceSharedResources = new DeviceSharedResources();
            ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel =
                _typesContainer.Resolve <ISharedResourcesGlobalViewModel>();

            sharedResourcesGlobalViewModel.InitializeFromResources(deviceSharedResources);

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var addedRow = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);

            configurationEditorViewModel.SelectedRows = new List <IEditorConfigurationItemViewModel>()
            {
                addedRow
            };


            sharedResourcesGlobalViewModel.AddAsSharedResourceWithContainer(addedRow, null, false);

            configurationEditorViewModel.CopyElementCommand.Execute(null);

            configurationEditorViewModel.SelectedRow = rootGroup;

            Assert.True(configurationEditorViewModel.PasteAsChildElementCommand.CanExecute(null));

            configurationEditorViewModel.PasteAsChildElementCommand.Execute(null);

            var copiedRow = rootGroup.ChildStructItemViewModels[1];


            configurationEditorViewModel.SelectedRow = (IEditorConfigurationItemViewModel)copiedRow;


            Assert.True(
                (configurationEditorViewModel.AddSelectedElementAsResourceCommand as RelayCommand).CanExecute(null));

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            Assert.AreEqual(result.RootConfigurationItemList.Count, 1);

            var itemList = (result.RootConfigurationItemList[0] as DefaultItemsGroup).ConfigurationItemList;

            CheckPropertyResultProperty(itemList, 1);
            CheckPropertyResultProperty(itemList, 1, 1);

            Assert.AreEqual(itemList.Count, 2);
        }
Exemplo n.º 5
0
        public void EditorAllFormattersPropFromSharedResourcesSave()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var deviceSharedResources = new DeviceSharedResources();
            ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel =
                _typesContainer.Resolve <ISharedResourcesGlobalViewModel>();

            sharedResourcesGlobalViewModel.InitializeFromResources(deviceSharedResources);

            CreateFormatterParametersForResourcesViewModel(1);
            CreateFormatterParametersForResourcesViewModel(2);
            CreateFormatterParametersForResourcesViewModel(3);
            CreateFormatterParametersForResourcesViewModel(4);
            CreateFormatterParametersForResourcesViewModel(5);
            CreateFormatterParametersForResourcesViewModel(6);


            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 1);
            AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 2);
            AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 3);
            AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 4);
            AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 5);
            AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 6);

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            Assert.AreEqual(result.RootConfigurationItemList.Count, 1);

            var itemList = (result.RootConfigurationItemList[0] as DefaultItemsGroup).ConfigurationItemList;

            CheckPropertyResultProperty(itemList, 1);
            CheckPropertyResultProperty(itemList, 2);
            CheckPropertyResultProperty(itemList, 3);
            CheckPropertyResultProperty(itemList, 4);
            CheckPropertyResultProperty(itemList, 5);
            CheckPropertyResultProperty(itemList, 6);

            Assert.AreEqual(itemList.Count, 6);
        }
Exemplo n.º 6
0
        public void ValidateEditorConfigurationWithErrorComplexProperty()
        {
            IResultingDeviceViewModel initialDevice = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>();


            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            var property = _typesContainer.Resolve <IComplexPropertyEditorViewModel>();

            rootGroup.ChildStructItemViewModels
            .Add(property);
            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);


            initialDevice.FragmentEditorViewModels
            .Add(configurationEditorViewModel);

            var res = _typesContainer.Resolve <IDeviceEditorViewModelValidator>()
                      .ValidateDeviceEditor(new List <IFragmentEditorViewModel>()
            {
                configurationEditorViewModel
            });

            Assert.True(res.Count == 0);

            var newDevice = initialDevice.GetDevice();


            IResultingDeviceViewModel newDeviceViewModel = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>();

            newDeviceViewModel.LoadDevice(newDevice);

            var resNew = _typesContainer.Resolve <IDeviceEditorViewModelValidator>()
                         .ValidateDeviceEditor(new List <IFragmentEditorViewModel>()
            {
                newDeviceViewModel.FragmentEditorViewModels.First()
            });

            Assert.True(resNew.Count == 0);
        }
Exemplo n.º 7
0
        public void CheckMigrator()
        {
            var rootItems = new List <IConfigurationItemViewModel>();


            var complexProperty = ConfigurationItemEditorViewModelFactory.Create().VisitComplexProperty(null) as ComplexPropertyEditorViewModel;

            complexProperty.AddSubProperty();
            complexProperty.AddSubProperty();
            complexProperty.AddSubProperty();
            complexProperty.SubPropertyEditorViewModels[0].BitNumbersInWord[0].ChangeValueByOwnerCommand.Execute(complexProperty.SubPropertyEditorViewModels[0]);
            complexProperty.SubPropertyEditorViewModels[1].BitNumbersInWord[10].ChangeValueByOwnerCommand.Execute(complexProperty.SubPropertyEditorViewModels[1]);
            complexProperty.SubPropertyEditorViewModels[2].BitNumbersInWord[12].ChangeValueByOwnerCommand.Execute(complexProperty.SubPropertyEditorViewModels[2]);



            var complexProperty2 = ConfigurationItemEditorViewModelFactory.Create().VisitComplexProperty(null) as ComplexPropertyEditorViewModel;

            complexProperty2.AddSubProperty();
            complexProperty2.SubPropertyEditorViewModels[0].BitNumbersInWord[0].ChangeValueByOwnerCommand.Execute(complexProperty2.SubPropertyEditorViewModels[0]);
            complexProperty2.IsGroupedProperty = true;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                ChildStructItemViewModels = new ObservableCollection <IConfigurationItemViewModel>()
                {
                    complexProperty, complexProperty2
                }
            };

            complexProperty.Parent  = rootGroup;
            complexProperty2.Parent = rootGroup;

            rootItems.Add(rootGroup);


            var resPrepared = ComplexPropertiesMigrator.GetAllComplexPropertiesInConfiguration(rootItems);

            Assert.AreEqual(2, resPrepared.Count);

            var res = ComplexPropertiesMigrator.MigrateComplexProperties(resPrepared);

            Assert.True(res.IsSuccess);
        }
Exemplo n.º 8
0
        public void CopyPasteDictionaryFormatter()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;


            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var addedRow = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 3, _typesContainer);


            configurationEditorViewModel.SelectedRows = new List <IEditorConfigurationItemViewModel>()
            {
                addedRow
            };


            configurationEditorViewModel.CopyElementCommand.Execute(null);

            configurationEditorViewModel.SelectedRow = rootGroup;

            configurationEditorViewModel.PasteAsChildElementCommand.Execute(null);


            var copiedRow = rootGroup.ChildStructItemViewModels[1];


            (addedRow.FormatterParametersViewModel.RelatedUshortsFormatterViewModel as
             DictionaryMatchingFormatterViewModel).KeyValuesDictionary[1].Value = "jopa11";

            Assert.True(((copiedRow as IPropertyEditorViewModel).FormatterParametersViewModel
                         .RelatedUshortsFormatterViewModel as
                         DictionaryMatchingFormatterViewModel).KeyValuesDictionary[1].Value == "jopa1");
        }
Exemplo n.º 9
0
        public async Task ShouldAllowAddManyDependencies()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            var prop1 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);
            var prop2 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);
            var prop3 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 3, _typesContainer);
            var prop4 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 4, _typesContainer);
            var prop5 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 5, _typesContainer);
            var prop6 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 6, _typesContainer);

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            Assert.AreEqual(result.RootConfigurationItemList.Count, 1);

            var itemList = (result.RootConfigurationItemList[0] as DefaultItemsGroup).ConfigurationItemList;


            var selected = new ObservableCollection <object>();

            selected.Add(prop1);
            selected.Add(prop2);
            selected.Add(prop5);

            configurationEditorViewModel.OnSelectionChangedCommand.Execute(selected);

            Assert.True(configurationEditorViewModel.IsMultiEditMode);
            Assert.True(configurationEditorViewModel.AddDependencyToManyProps.CanExecute(null));
        }
Exemplo n.º 10
0
        public async Task ShouldCutPasteRootProps()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            var prop1 = AddPropertyViewModel(configurationEditorViewModel.RootConfigurationItemViewModels, 1, _typesContainer);
            var prop2 = AddPropertyViewModel(configurationEditorViewModel.RootConfigurationItemViewModels, 2, _typesContainer);
            var prop3 = AddPropertyViewModel(configurationEditorViewModel.RootConfigurationItemViewModels, 3, _typesContainer);
            var prop4 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 4, _typesContainer);
            var prop5 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 5, _typesContainer);
            var prop6 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 6, _typesContainer);

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);


            configurationEditorViewModel.SelectedRows = new List <IEditorConfigurationItemViewModel>()
            {
                prop1
            };



            Assert.True(configurationEditorViewModel.CutElementCommand.CanExecute(null));


            configurationEditorViewModel.CutElementCommand.Execute(null);
            configurationEditorViewModel.SelectedRow = rootGroup;
            configurationEditorViewModel.PasteAsChildElementCommand.Execute(null);

            Assert.AreEqual(rootGroup.ChildStructItemViewModels.Count, 4);
        }
Exemplo n.º 11
0
        public void EditorCopyManyProps()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;


            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var addedRow1 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);
            var addedRow2 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);
            var addedRow3 = AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 3, _typesContainer);


            configurationEditorViewModel.SelectedRows = new List <IEditorConfigurationItemViewModel>()
            {
                addedRow1, addedRow2, addedRow3
            };


            configurationEditorViewModel.CopyElementCommand.Execute(null);

            configurationEditorViewModel.SelectedRow = rootGroup;

            configurationEditorViewModel.PasteAsChildElementCommand.Execute(null);


            var copiedRow = rootGroup.ChildStructItemViewModels[1];

            Assert.True(rootGroup.ChildStructItemViewModels.Count == 6);
        }
Exemplo n.º 12
0
        public void RemoveSubproperty()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };


            var complexPropertyEditorViewModel =
                ConfigurationItemEditorViewModelFactory.Create().VisitComplexProperty(null) as
                IComplexPropertyEditorViewModel;

            var subprop1 = ConfigurationItemEditorViewModelFactory.Create().WithParent(complexPropertyEditorViewModel)
                           .VisitSubProperty(null) as ISubPropertyEditorViewModel;
            var subprop2 = ConfigurationItemEditorViewModelFactory.Create().WithParent(complexPropertyEditorViewModel)
                           .VisitSubProperty(null) as ISubPropertyEditorViewModel;


            complexPropertyEditorViewModel.ChildStructItemViewModels.Add(subprop1);
            complexPropertyEditorViewModel.ChildStructItemViewModels.Add(subprop2);
            complexPropertyEditorViewModel.SubPropertyEditorViewModels.Add(subprop1);
            complexPropertyEditorViewModel.SubPropertyEditorViewModels.Add(subprop2);

            subprop1.BitNumbersInWord =
                complexPropertyEditorViewModel.MainBitNumbersInWordCollection;
            subprop2.BitNumbersInWord =
                complexPropertyEditorViewModel.MainBitNumbersInWordCollection;

            complexPropertyEditorViewModel.MainBitNumbersInWordCollection[0].ChangeValueByOwnerCommand
            .Execute(subprop1);
            complexPropertyEditorViewModel.MainBitNumbersInWordCollection[1].ChangeValueByOwnerCommand
            .Execute(subprop1);
            complexPropertyEditorViewModel.MainBitNumbersInWordCollection[2].ChangeValueByOwnerCommand
            .Execute(subprop2);
            complexPropertyEditorViewModel.MainBitNumbersInWordCollection[3].ChangeValueByOwnerCommand
            .Execute(subprop2);

            rootGroup.ChildStructItemViewModels.Add(complexPropertyEditorViewModel);

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            var resSubProp1 =
                ((result.RootConfigurationItemList[0] as IItemsGroup).ConfigurationItemList[0] as IComplexProperty)
                .SubProperties[0];
            var resSubProp2 =
                ((result.RootConfigurationItemList[0] as IItemsGroup).ConfigurationItemList[0] as IComplexProperty)
                .SubProperties[1];

            Assert.True(resSubProp1.BitNumbersInWord.Count == 2);
            Assert.True(resSubProp2.BitNumbersInWord.Count == 2);

            Assert.True(resSubProp1.BitNumbersInWord.Contains(15));
            Assert.True(resSubProp1.BitNumbersInWord.Contains(14));
            Assert.True(resSubProp2.BitNumbersInWord.Contains(13));
            Assert.True(resSubProp2.BitNumbersInWord.Contains(12));


            complexPropertyEditorViewModel.RemoveChildItem(subprop2);

            Assert.True(complexPropertyEditorViewModel.MainBitNumbersInWordCollection.All(model => model.Owner != subprop2));
            Assert.True(complexPropertyEditorViewModel.MainBitNumbersInWordCollection.First(model => model.NumberOfBit == 13).Value == false);
            Assert.True(complexPropertyEditorViewModel.MainBitNumbersInWordCollection.First(model => model.NumberOfBit == 12).Value == false);

            Assert.True(complexPropertyEditorViewModel.MainBitNumbersInWordCollection.First(model => model.NumberOfBit == 13).Owner == null);
            Assert.True(complexPropertyEditorViewModel.MainBitNumbersInWordCollection.First(model => model.NumberOfBit == 12).Owner == null);
        }
Exemplo n.º 13
0
        public void GroupFilterSaveLoad()
        {
            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            rootGroup.FilterViewModels.AddRange(new ObservableCollection <IFilterViewModel>()
            {
                new FilterViewModel(new ObservableCollection <IConditionViewModel>())
                {
                    Name = "F1"
                },
                new FilterViewModel(new ObservableCollection <IConditionViewModel>()
                {
                    new CompareConditionViewModel(new List <string>()
                    {
                        "c1"
                    })
                    {
                        SelectedCondition    = ConditionsEnum.Equal.ToString(),
                        UshortValueToCompare = 1
                    }
                })
                {
                    Name = "F2"
                }
            });

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var result = ConfigurationFragmentFactory.CreateConfiguration(configurationEditorViewModel);

            var groupFilter = (result.RootConfigurationItemList[0] as IItemsGroup).GroupFilter as GroupFilterInfo;

            Assert.True(groupFilter.Filters.Count == 2);

            DefaultFilter defaultFilter1 = groupFilter.Filters[0] as DefaultFilter;

            DefaultFilter defaultFilter2 = groupFilter.Filters[1] as DefaultFilter;

            Assert.True(defaultFilter1.Conditions.Count == 0);
            Assert.True(defaultFilter1.Name == "F1");

            Assert.True(defaultFilter2.Conditions.Count == 1);
            Assert.True(defaultFilter2.Name == "F2");

            var condition = defaultFilter2.Conditions[0] as CompareCondition;

            Assert.True(condition.ConditionsEnum == ConditionsEnum.Equal);
            Assert.True(condition.UshortValueToCompare == 1);


            ConfigurationItemEditorViewModelFactory configurationItemEditorViewModelFactory =
                ConfigurationItemEditorViewModelFactory.Create();

            var loadedRootItem =
                configurationItemEditorViewModelFactory.VisitItemsGroup(
                    result.RootConfigurationItemList[0] as IItemsGroup);


            FilterViewModel filterViewModel1 =
                (loadedRootItem as IConfigurationGroupEditorViewModel).FilterViewModels[0] as FilterViewModel;

            FilterViewModel filterViewModel2 =
                (loadedRootItem as IConfigurationGroupEditorViewModel).FilterViewModels[1] as FilterViewModel;

            Assert.True(filterViewModel1.Name == "F1");
            Assert.True(filterViewModel2.Name == "F2");

            Assert.True(filterViewModel1.ConditionViewModels.Count == 0);
            Assert.True(filterViewModel2.ConditionViewModels.Count == 1);

            CompareConditionViewModel compareConditionViewModel =
                filterViewModel2.ConditionViewModels[0] as CompareConditionViewModel;

            Assert.True(compareConditionViewModel.SelectedCondition == ConditionsEnum.Equal.ToString());
            Assert.True(compareConditionViewModel.UshortValueToCompare == 1);
        }
Exemplo n.º 14
0
        public void ValidateEditorRemovePropertySharedResource()
        {
            IResultingDeviceViewModel initialDevice = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>();

            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var deviceSharedResources = new DeviceSharedResources();
            ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel =
                _typesContainer.Resolve <ISharedResourcesGlobalViewModel>();

            sharedResourcesGlobalViewModel.InitializeFromResources(deviceSharedResources);

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);

            var property = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);

            property.Name = "Pupa";

            configurationEditorViewModel.SelectedRow = property;

            sharedResourcesGlobalViewModel.AddAsSharedResourceWithContainer(property, null, false);

            property.Parent = rootGroup;

            property.DeleteElement();



            var property2 = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);

            property2.DependencyViewModels.Add(
                new ConditionResultDependencyViewModel(new List <IResultViewModel>(), new List <IConditionViewModel>())
            {
                SelectedConditionViewModel = new CompareResourceConditionViewModel(
                    _typesContainer.Resolve <ISharedResourcesGlobalViewModel>(),
                    new List <string>(Enum.GetNames(typeof(ConditionsEnum))))
                {
                    ReferencedResourcePropertyName = "Pupa"
                }
            });



            initialDevice.FragmentEditorViewModels
            .Add(configurationEditorViewModel);

            var res = _typesContainer.Resolve <IDeviceEditorViewModelValidator>()
                      .ValidateDeviceEditor(new List <IFragmentEditorViewModel>()
            {
                configurationEditorViewModel
            });

            Assert.True(res.Count == 1);
            Assert.True(res[0].ErrorMessage.Contains(ApplicationGlobalNames.StatusMessages.RESOURCE_FOR_DEPENDENCY_NOT_FOUND_MESSAGE));
        }
Exemplo n.º 15
0
        public void ValidateEditorConfigurationWithMissingResourceDependencyError()
        {
            IResultingDeviceViewModel initialDevice = Program.GetApp().Container.Resolve <IResultingDeviceViewModel>();


            var configurationEditorViewModel = _typesContainer.Resolve <IFragmentEditorViewModel>(
                ApplicationGlobalNames.FragmentInjectcionStrings.CONFIGURATION +
                ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as ConfigurationEditorViewModel;

            var rootGroup = new ConfigurationGroupEditorViewModel()
            {
                Name = "root"
            };

            var property = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 1, _typesContainer);

            property.DependencyViewModels.Add(
                new ConditionResultDependencyViewModel(new List <IResultViewModel>(), new List <IConditionViewModel>())
            {
                SelectedConditionViewModel = new CompareResourceConditionViewModel(
                    _typesContainer.Resolve <ISharedResourcesGlobalViewModel>(),
                    new List <string>(Enum.GetNames(typeof(ConditionsEnum))))
                {
                    ReferencedResourcePropertyName = ""
                }
            });

            var property2 = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);

            property2.DependencyViewModels.Add(
                new ConditionResultDependencyViewModel(new List <IResultViewModel>(), new List <IConditionViewModel>())
            {
                SelectedConditionViewModel = new CompareResourceConditionViewModel(
                    _typesContainer.Resolve <ISharedResourcesGlobalViewModel>(),
                    new List <string>(Enum.GetNames(typeof(ConditionsEnum))))
                {
                    ReferencedResourcePropertyName = "Pupa"
                }
            });


            var property3 = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);

            property3.DependencyViewModels.Add(
                new ConditionResultDependencyViewModel(new List <IResultViewModel>(), new List <IConditionViewModel>())
            {
                SelectedConditionViewModel = new RegexMatchConditionViewModel(
                    _typesContainer.Resolve <ISharedResourcesGlobalViewModel>())
                {
                    ReferencedResourcePropertyName = "Pupa"
                }
            });
            var property4 = EditorHelpers.AddPropertyViewModel(rootGroup.ChildStructItemViewModels, 2, _typesContainer);


            property4.DependencyViewModels.Add(
                new ConditionResultDependencyViewModel(new List <IResultViewModel>(), new List <IConditionViewModel>())
            {
                SelectedConditionViewModel = new RegexMatchConditionViewModel(
                    _typesContainer.Resolve <ISharedResourcesGlobalViewModel>())
                {
                    ReferencedResourcePropertyName = ""
                }
            });


            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);


            initialDevice.FragmentEditorViewModels
            .Add(configurationEditorViewModel);

            var res = _typesContainer.Resolve <IDeviceEditorViewModelValidator>()
                      .ValidateDeviceEditor(new List <IFragmentEditorViewModel>()
            {
                configurationEditorViewModel
            });

            Assert.True(res.Count == 4);
        }