Beispiel #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);
        }
Beispiel #2
0
        public async Task BitOwnershipHelperCheckNoSameAddresses()
        {
            List <IConfigurationItemViewModel> list = new List <IConfigurationItemViewModel>();


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

            var res = BitOwnershipHelper.CreateBitViewModelsWithOwnership(
                property, list);

            Assert.True(res.All(model => model.IsBitEditEnabled));
        }
Beispiel #3
0
        public void ValidateEditorConfigurationWithError()
        {
            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.FormatterParametersViewModel.RelatedUshortsFormatterViewModel = null;

            configurationEditorViewModel.RootConfigurationItemViewModels.Add(rootGroup);


            initialDevice.FragmentEditorViewModels
            .Add(configurationEditorViewModel);

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

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

            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 == 1);
        }
Beispiel #4
0
        public async Task BitOwnershipHelperCheckOneBitWithSameAddress()
        {
            List <IConfigurationItemViewModel> list = new List <IConfigurationItemViewModel>();


            var property   = EditorHelpers.AddPropertyViewModel(list, 1, _typesContainer);
            var secondProp = EditorHelpers.AddPropertyViewModel(list, 1, _typesContainer);

            secondProp.IsFromBits = true;
            property.IsFromBits   = true;
            secondProp.BitNumbersInWord[15].IsChecked = true;
            var res = BitOwnershipHelper.CreateBitViewModelsWithOwnership(
                property, list);

            Assert.False(res[15].IsBitEditEnabled);
            Assert.True(res.Where(model => model != res[15]).All(model => model.IsBitEditEnabled));
        }
Beispiel #5
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));
        }
Beispiel #6
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);
        }