예제 #1
0
        public override void Execute(object obj)
        {
            var currentRegion = _regionHelper.CurrentRegionName;
            MessageInteraction interaction = null;

            if (currentRegion == MainRegionViewNames.SettingsView)
            {
                var currentSettings = _currentSettingsProvider.Settings;
                var result          = _appSettingsChecker.CheckDefaultViewers(currentSettings.ApplicationSettings);
                var resultDict      = new ActionResultDict();
                resultDict.Add(Translation.DefaultViewer, result);
                interaction = DetermineInteraction(resultDict, settingsChanged: false);
            }
            else if (currentRegion == MainRegionViewNames.ProfilesView)
            {
                var currentSettings = _currentSettingsProvider.Settings;
                var resultDict      = _profileChecker.CheckProfileList(currentSettings.ConversionProfiles, currentSettings.ApplicationSettings.Accounts);
                var settingsChanged = _settingsChanged.HaveChanged();
                interaction = DetermineInteraction(resultDict, settingsChanged);
            }

            if (interaction != null)
            {
                _interactionRequest.Raise(interaction, ResolveInteractionResult);
            }
            else
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
            }
        }
        public void Setup()
        {
            _interactionRequest = new UnitTestInteractionRequest();

            _settings = new PdfCreatorSettings(null);
            _currentSettingsProvider = Substitute.For <ICurrentSettingsProvider>();
            _currentSettingsProvider.Settings.Returns(_settings);
            _currentSettingsProvider.Profiles.Returns(_settings.ConversionProfiles);
            _currentSettingsProvider.SelectedProfile.Returns(_settings.ConversionProfiles.FirstOrDefault());

            var translationUpdater = new DesignTimeTranslationUpdater();

            _regionHelper = Substitute.For <IRegionHelper>();

            _profileChecker = Substitute.For <IProfileChecker>();
            _profileChecker.CheckProfileList(_settings.ConversionProfiles, _settings.ApplicationSettings.Accounts)
            .Returns(new ActionResultDict());

            _appSettingsChecker = Substitute.For <IAppSettingsChecker>();
            _appSettingsChecker.CheckDefaultViewers(Arg.Any <ApplicationSettings>())
            .Returns(new ActionResult());

            _settingsChanged = Substitute.For <ISettingsChanged>();

            _command = new EvaluateSettingsAndNotifyUserCommand(_interactionRequest, _currentSettingsProvider,
                                                                translationUpdater, _regionHelper, _profileChecker,
                                                                _appSettingsChecker, _settingsChanged);

            _commandTester = new WaitableCommandTester <EvaluateSettingsAndNotifyUserCommand>(_command);

            _translation = new EvaluateSettingsAndNotifyUserTranslation();

            _actionResultWithError = new ActionResult((ErrorCode)123456789);
            _errorsInProfile       = new ActionResultDict();
            _errorsInProfile.Add("Some Profile", _actionResultWithError);
        }
 private void SetErrorsInAppSettings()
 {
     _appSettingsChecker.CheckDefaultViewers(_settings.ApplicationSettings)
     .Returns(_actionResultWithError);
 }