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); }
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); }
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); }
public ResultingDeviceViewModel(IDevice device, ITypesContainer container, ILocalizerService localizerService, IDeviceSharedResources deviceSharedResources, IApplicationGlobalCommands applicationGlobalCommands, ISharedResourcesGlobalViewModel sharedResourcesGlobalViewModel, IFragmentEditorViewModelFactory fragmentEditorViewModelFactory, IConnectionStateViewModelFactory connectionStateViewModelFactory, ISerializerService serializerService) { _device = device; _container = container; _deviceSharedResources = deviceSharedResources; _applicationGlobalCommands = applicationGlobalCommands; _sharedResourcesGlobalViewModel = sharedResourcesGlobalViewModel; _fragmentEditorViewModelFactory = fragmentEditorViewModelFactory; _connectionStateViewModelFactory = connectionStateViewModelFactory; _serializerService = serializerService; DeviceName = localizerService.GetLocalizedString(ApplicationGlobalNames.DefaultStringsForUi.NEW_DEVICE_STRING); FragmentEditorViewModels = new ObservableCollection <IFragmentEditorViewModel>(); sharedResourcesGlobalViewModel.InitializeFromResources(deviceSharedResources); NavigateToConnectionTestingCommand = new RelayCommand(OnNavigateToConnectionTestingExecute); }
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)); }