Esempio n. 1
0
        public void ValidateEditorConfigurationWithMissingResource()
        {
            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"
            };

            EditorHelpers.AddPropertyWithFormatterFromResourceViewModel(rootGroup.ChildStructItemViewModels, 1);

            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);
        }