Beispiel #1
0
        //
        // GET: /MultiD/
        public ActionResult Index()
        {
            MultiDialogueModel userView;

            try
            {
                userView = ViewStateManager.getViewFromViewState <MultiDialogueModel>(_multiDialogViewIndex);
            }
            catch (KeyNotFoundException)
            {
                userView = new MultiDialogueModel();
            }

            RAM_HelloWorldRepository rep = new RAM_HelloWorldRepository();

            rep.populateWithTestData();
            MultipleDialogs_Processor viewProcessor = new MultipleDialogs_Processor(userView, rep);

            _multiDialogViewIndex = viewProcessor.UserView.viewID;

            //viewProcessor.AddUserAction(new Dialog_UserActions.Action_SetSelectedLanguage { newLang = "ru" });
            //viewProcessor.AddUserAction(new Dialog_UserActions.Action_ReportUserName { userName = "******" });
            //viewProcessor.InvokeUserActions();
            viewProcessor.InvokeUserActions(ExtractRequestActions_Index());
            //viewProcessor.InvokeUserAction(new Dialog_UserActions.Action_SetSelectedLanguage {newLang = "de"});

            return(View("Index", viewProcessor.UserView));
        }
        public void SaveAndRestoreSampleUserView()
        {
            //Arrange
            SampleUserView beforeView = ViewStateManager.getViewFromViewState <SampleUserView>(0);

            Assert.True(String.IsNullOrEmpty(beforeView.strProp_SampleStringProperty));
            beforeView.strProp_SampleStringProperty = "sampleStr";

            Assert.False(beforeView.boolProp_SampleBooleanProperty);
            beforeView.boolProp_SampleBooleanProperty = true;

            Assert.Equal(0, beforeView.intProp_SampleBooleanProperty);
            beforeView.intProp_SampleBooleanProperty = 10;

            Assert.Equal(0, beforeView.subViews_SampleSubViews.Count);
            for (int i = 1; i < 4; i++)
            {
                beforeView.subViews_SampleSubViews.Add(i);
            }

            //Act
            ViewStateManager.saveViewToViewState(beforeView);
            SampleUserView restoredView = ViewStateManager.getViewFromViewState <SampleUserView>(beforeView.viewID);

            //Assert
            Assert.Equal(beforeView.strProp_SampleStringProperty, restoredView.strProp_SampleStringProperty);
            Assert.True(restoredView.boolProp_SampleBooleanProperty);
            Assert.Equal(beforeView.intProp_SampleBooleanProperty, restoredView.intProp_SampleBooleanProperty);
            Assert.Equal(3, beforeView.subViews_SampleSubViews.Count);
            for (int i = 1; i < 4; i++)
            {
                Assert.Equal(i, beforeView.subViews_SampleSubViews[i - 1]);
            }
        }
        public List <string> getAvailableLanguages()
        {
            List <string> ausgabe = new List <string>();

            foreach (int spracheID in UserView.subViews_availableLanguages)
            {
                IdDescriptionPaar tmpSprache = ViewStateManager.getViewFromViewState <IdDescriptionPaar>(spracheID);
                ausgabe.Add(tmpSprache.strProp_shortID);
            }

            return(ausgabe);
        }
 private void initUserView()
 {
     if (UserView.subViews_DialogWithUser.Count > 4)
     {
         UserView.boolProp_isActionPossible_AddNewDialog = false;
     }
     else
     {
         UserView.boolProp_isActionPossible_AddNewDialog = true;
     }
     foreach (int dialogID in UserView.subViews_DialogWithUser)
     {
         _SubDialogs.Add(dialogID, new Dialog_Processor(ViewStateManager.getViewFromViewState <Mock_UI_DialogWithUser>(dialogID), _repository));
     }
 }
        private void AddNewDialog(Action_AddNewDialog act)
        {
            Mock_UI_DialogWithUser newDlg = ViewStateManager.getViewFromViewState <Mock_UI_DialogWithUser>(0);

            newDlg.boolProp_isActionPossible_SelectLanguage = true;

            UserView.subViews_DialogWithUser.Add(newDlg.viewID);
            ViewStateManager.saveViewToViewState(newDlg);

            _SubDialogs.Add(newDlg.viewID, new Dialog_Processor(newDlg, _repository));

            if (this.UserView.subViews_DialogWithUser.Count > 0)
            {
                this.UserView.boolProp_isActionPossible_RemoveLastDialog = true;
            }
            if (this.UserView.subViews_DialogWithUser.Count > 4)
            {
                this.UserView.boolProp_isActionPossible_AddNewDialog = false;
            }
        }
        public static I_UI_DialogWithUser Get_UI_DialogWithUser(int viewID)
        {
            I_UI_DialogWithUser ausgabe;

            switch (GUI)
            {
            case GuiToTest.MockUI:
                ausgabe = ViewStateManager.getViewFromViewState <Mock_UI_DialogWithUser>(viewID);
                break;

            case GuiToTest.AspMvcApplication:
                ausgabe = ViewStateManager.getViewFromViewState <SingleDialogueModelHelper>(viewID);
                break;

            default:
                throw new NotImplementedException();
            }

            return(ausgabe);
        }
        private void initLanguages()
        {
            foreach (KeyValuePair <string, string> lang in _repository.GetAllLanguages())
            {
                bool isLangAdded = false;
                foreach (int aID in UserView.subViews_availableLanguages)
                {
                    if (ViewStateManager.getViewFromViewState <IdDescriptionPaar>(aID).strProp_shortID == lang.Key)
                    {
                        isLangAdded = true;
                        break;
                    }
                }
                if (!isLangAdded)
                {
                    IdDescriptionPaar newLang = ViewStateManager.getViewFromViewState <IdDescriptionPaar>(0);
                    newLang.strProp_shortID     = lang.Key;
                    newLang.strProp_description = lang.Value;

                    UserView.subViews_availableLanguages.Add(newLang.viewID);
                    ViewStateManager.saveViewToViewState(newLang);
                }
            }
        }
 public MultipleDialogs_Processor Get_MultiDialog_Processor(int viewID)
 {
     return(new MultipleDialogs_Processor(ViewStateManager.getViewFromViewState <Mock_UI_MultipleDialogs>(viewID), new Mock_HelloWorldRepository()));
 }