Ejemplo n.º 1
0
        public async Task OfflineConnectionConfigurationButtonsAvailbility()
        {
            await _typesContainer.Resolve <IDevicesContainerService>()
            .ConnectDeviceAsync(_device, new OfflineConnection());

            int isChanagedTriggered  = 0;
            int isChanagedTriggered1 = 0;
            int isChanagedTriggered2 = 0;

            var optionCommands = new List <RelayCommand>()
            {
                _configurationFragmentViewModel.FragmentOptionsViewModel.FragmentOptionGroupViewModels
                .First(model => model.NameKey == "Device").FragmentOptionCommandViewModels
                .First(model => model.TitleKey == ApplicationGlobalNames.UiCommandStrings.READ_STRING_KEY)
                .OptionCommand as RelayCommand,
                _configurationFragmentViewModel.FragmentOptionsViewModel.FragmentOptionGroupViewModels
                .First(model => model.NameKey == "Device").FragmentOptionCommandViewModels
                .First(model => model.TitleKey == ConfigurationKeys.WRITE_LOCAL_VALUES_TO_DEVICE_STRING_KEY)
                .OptionCommand as RelayCommand,
                _configurationFragmentViewModel.FragmentOptionsViewModel.FragmentOptionGroupViewModels
                .First(model => model.NameKey == "Device").FragmentOptionCommandViewModels
                .First(model => model.TitleKey == ConfigurationKeys.TRANSFER_FROM_DEVICE_TO_LOCAL_STRING_KEY)
                .OptionCommand as RelayCommand,
            };

            Assert.False(optionCommands.Any(command => command.CanExecute(null)));

            optionCommands[0].CanExecuteChanged += (sender, args) => { isChanagedTriggered++; };
            optionCommands[1].CanExecuteChanged += (sender, args) => { isChanagedTriggered1++; };
            optionCommands[2].CanExecuteChanged += (sender, args) => { isChanagedTriggered2++; };

            await _typesContainer.Resolve <IDevicesContainerService>()
            .ConnectDeviceAsync(_device, new MockConnection());

            await _configurationFragmentViewModel.SetFragmentOpened(true);

            Assert.True(await TestsUtils.WaitUntil(
                            () => optionCommands.All(command => command.CanExecute(null)), 30000));
            Assert.True(isChanagedTriggered > 0);
            Assert.True(isChanagedTriggered1 > 0);
            Assert.True(isChanagedTriggered2 > 0);
            //open again and it must not start reading
            await _configurationFragmentViewModel.SetFragmentOpened(true);

            Assert.True(optionCommands.All(command => command.CanExecute(null)));
        }
Ejemplo n.º 2
0
        public async Task OnSetup()
        {
            Program.RefreshProject();
            _typesContainer =
                new TypesContainer(Program.GetApp().Container.Resolve(typeof(IUnityContainer)) as IUnityContainer);

            _device        = Program.GetDevice();
            _configuration =

                _device.DeviceFragments.First(fragment => fragment.StrongName == "Configuration") as
                IDeviceConfiguration;

            _shell = _typesContainer.Resolve <ShellViewModel>();
            var deviceMemory = new DeviceMemory();


            _device.DeviceMemory            = deviceMemory;
            _configurationFragmentViewModel = null;

            _configurationFragmentViewModel = _shell.ProjectBrowserViewModel.DeviceViewModels[0].FragmentViewModels
                                              .First(model => model.NameForUiKey == "Configuration") as
                                              RuntimeConfigurationViewModel;
            _readCommand = _configurationFragmentViewModel.FragmentOptionsViewModel.FragmentOptionGroupViewModels
                           .First(model => model.NameKey == "Device").FragmentOptionCommandViewModels
                           .First(model => model.TitleKey == ApplicationGlobalNames.UiCommandStrings.READ_STRING_KEY)
                           .OptionCommand as RelayCommand;
            await _typesContainer.Resolve <IDevicesContainerService>()
            .ConnectDeviceAsync(_device, new MockConnection());

            _shell.ActiveFragmentViewModel = new FragmentPaneViewModel()
            {
                FragmentViewModel = _configurationFragmentViewModel
            };
            await _configurationFragmentViewModel.SetFragmentOpened(true);

            _measuringMonitorViewModel = _shell.ProjectBrowserViewModel.DeviceViewModels[0].FragmentViewModels
                                         .First(model => model.NameForUiKey == "MeasuringMonitor") as
                                         MeasuringMonitorViewModel;
        }