Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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));
        }
Esempio n. 4
0
 private void OnAddAsResource()
 {
     _sharedResourcesGlobalViewModel.AddAsSharedResourceWithContainer(this);
 }