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 void SelectValidLanguage_UserNameAlreadySubmitted()
        {
            //Arrange
            string           newLang   = "de";
            Dialog_Processor processor = Get_Dialog_Processor(0);

            processor.InvokeUserAction(new BasementHelloWorldCommonParts.UA_Processors.Dialog_Processor.Action_SetSelectedLanguage {
                newLang = "fr"
            });
            processor.InvokeUserAction(new BasementHelloWorldCommonParts.UA_Processors.Dialog_Processor.Action_ReportUserName {
                userName = "******"
            });
            Assert.Equal("helloUserMessage_fr_Fransois", processor.UserView.strProp_helloUserMessageText);
            ViewStateManager.saveViewToViewState(processor.UserView);
            int viewID = processor.UserView.viewID;

            //Act
            processor = Get_Dialog_Processor(viewID);
            processor.InvokeUserAction(new BasementHelloWorldCommonParts.UA_Processors.Dialog_Processor.Action_SetSelectedLanguage {
                newLang = newLang
            });

            //Assert
            Assert.Equal(newLang, processor.UserView.strProp_selectedLanguage);
            Assert.Equal("helloUserMessage_de_Fransois", processor.UserView.strProp_helloUserMessageText);
            Assert.False(processor.UserView.boolProp_greetingVisible);
            Assert.False(processor.UserView.boolProp_isActionPossible_TellUserName);
            Assert.True(processor.UserView.boolProp_isActionPossible_AnswerChatAgainQuestion);
            Assert.Equal("questionForChatingAgain_de", processor.UserView.strProp_questionForChatingAgain);
            Assert.Equal("yes_de", processor.UserView.strProp_actionExplanation_DoChatAgain);
            Assert.Equal("no_de", processor.UserView.strProp_actionExplanation_DontChatAgain);
        }
        protected override IAsyncResult BeginExecute(System.Web.Routing.RequestContext requestContext, AsyncCallback callback, object state)
        {
            _viewStateManager = new ViewStateManager(requestContext.HttpContext.Request, ViewBag, this.GetViewStateFieldName());
            LoadViewState(_viewStateManager);

            return base.BeginExecute(requestContext, callback, state);
        }
        public void ChangeSubViews()
        {
            //Arange
            MultipleDialogs_Processor processor = Get_MultiDialog_Processor(0);

            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.InvokeUserActions();
            Assert.Equal(3, processor.UserView.subViews_DialogWithUser.Count);
            int viewID = processor.UserView.viewID;
            int d1ID   = processor.UserView.subViews_DialogWithUser[0];
            int d2ID   = processor.UserView.subViews_DialogWithUser[1];
            int d3ID   = processor.UserView.subViews_DialogWithUser[2];

            //Act
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_SetSelectedLanguage {
                newLang = "fr", subDialogID = d1ID
            });
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_SetSelectedLanguage {
                newLang = "en", subDialogID = d2ID
            });
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_SetSelectedLanguage {
                newLang = "ru", subDialogID = d3ID
            });
            processor.InvokeUserActions();

            ViewStateManager.saveViewToViewState(processor.UserView);

            //Assert
            Assert.Equal("fr", TestSettings.Get_UI_DialogWithUser(d1ID).strProp_selectedLanguage);
            Assert.Equal("en", TestSettings.Get_UI_DialogWithUser(d2ID).strProp_selectedLanguage);
            Assert.Equal("ru", TestSettings.Get_UI_DialogWithUser(d3ID).strProp_selectedLanguage);
        }
        public void AnswerChatAgainQuestion_NO()
        {
            //Arrange
            Dialog_Processor processor = Get_Dialog_Processor(0);

            processor.InvokeUserAction(new BasementHelloWorldCommonParts.UA_Processors.Dialog_Processor.Action_SetSelectedLanguage {
                newLang = "de"
            });
            ViewStateManager.saveViewToViewState(processor.UserView);
            int viewID = processor.UserView.viewID;

            processor = Get_Dialog_Processor(viewID);
            processor.InvokeUserAction(new BasementHelloWorldCommonParts.UA_Processors.Dialog_Processor.Action_ReportUserName {
                userName = "******"
            });
            ViewStateManager.saveViewToViewState(processor.UserView);
            viewID = processor.UserView.viewID;

            processor = Get_Dialog_Processor(viewID);

            //Act
            processor.InvokeUserAction(new BasementHelloWorldCommonParts.UA_Processors.Dialog_Processor.Action_AcceptChatAgain {
                needChatAgain = false
            });

            //Assert
            Assert.Equal("", processor.UserView.strProp_selectedLanguage);
            Assert.Equal("", processor.UserView.strProp_userName);
            //Resetting all dialogue fields
            Assert.False(processor.UserView.boolProp_isActionPossible_TellUserName);
            Assert.False(processor.UserView.boolProp_greetingVisible);
            Assert.False(processor.UserView.boolProp_isActionPossible_AnswerChatAgainQuestion);
        }
        public void InvokeUserActions(UserActionsQuery actionsQuery)
        {
            foreach (OpaUserAction act in actionsQuery.actions)
            {
                InvokeUserAction(act);
            }

            ViewStateManager.saveViewToViewState(UserView);
        }
Beispiel #8
0
        public Main(IRootViewModelFactory viewModelFactory)
        {
            DataContext = viewModelFactory.CreateMainViewModel();

            ViewStateManager = new ViewStateManager(viewModelFactory);
            CurrentPage      = ViewStateManager.Navigator.CurrentBody;

            InitializeComponent();
        }
        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 RemoveLastDialog(Action_RemoveLastDialog act)
 {
     if (UserView.subViews_DialogWithUser.Count > 0)
     {
         ViewStateManager.Delete(UserView.subViews_DialogWithUser[UserView.subViews_DialogWithUser.Count - 1]);
         _SubDialogs.Remove(UserView.subViews_DialogWithUser[UserView.subViews_DialogWithUser.Count - 1]);
         UserView.subViews_DialogWithUser.RemoveAt(UserView.subViews_DialogWithUser.Count - 1);
         if (this.UserView.subViews_DialogWithUser.Count < 1)
         {
             this.UserView.boolProp_isActionPossible_RemoveLastDialog = false;
         }
         if (this.UserView.subViews_DialogWithUser.Count < 5)
         {
             this.UserView.boolProp_isActionPossible_AddNewDialog = true;
         }
     }
 }
        public void AnswerChatAgainQuestion_NO()
        {
            //Arrange
            MultipleDialogs_Processor processor = Get_MultiDialog_Processor(0);

            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.InvokeUserActions();
            Assert.Equal(3, processor.UserView.subViews_DialogWithUser.Count);
            int viewID = processor.UserView.viewID;
            int d2ID   = processor.UserView.subViews_DialogWithUser[1];

            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_SetSelectedLanguage {
                newLang = "de", subDialogID = d2ID
            });
            processor.InvokeUserActions();
            ViewStateManager.saveViewToViewState(processor.UserView);

            processor = Get_MultiDialog_Processor(viewID);

            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_ReportUserName {
                userName = "******", subDialogID = d2ID
            });
            processor.InvokeUserActions();

            ViewStateManager.saveViewToViewState(processor.UserView);

            processor = Get_MultiDialog_Processor(viewID);

            //Act
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_AcceptChatAgain {
                needChatAgain = false, subDialogID = d2ID
            });
            processor.InvokeUserActions();

            I_UI_DialogWithUser editedSubDlg = TestSettings.Get_UI_DialogWithUser(d2ID);

            //Assert
            Assert.Equal("", editedSubDlg.strProp_selectedLanguage);
            Assert.Equal("", editedSubDlg.strProp_userName);
            //Resetting all dialogue fields
            Assert.False(editedSubDlg.boolProp_isActionPossible_TellUserName);
            Assert.False(editedSubDlg.boolProp_greetingVisible);
            Assert.False(editedSubDlg.boolProp_isActionPossible_AnswerChatAgainQuestion);
        }
        public void SubDialog_SubmitUserName_languageAlreadySelected()
        {
            //Arrange
            string newUserName = "******";
            MultipleDialogs_Processor processor = Get_MultiDialog_Processor(0);

            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.Action_AddNewDialog());
            processor.InvokeUserActions();
            Assert.Equal(3, processor.UserView.subViews_DialogWithUser.Count);
            int viewID = processor.UserView.viewID;
            int d2ID   = processor.UserView.subViews_DialogWithUser[1];

            processor.AddUserAction(processor.UserView.viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_SetSelectedLanguage {
                newLang = "fr", subDialogID = d2ID
            });
            processor.InvokeUserActions();

            ViewStateManager.saveViewToViewState(processor.UserView);

            //Act
            processor = Get_MultiDialog_Processor(viewID);
            processor.AddUserAction(viewID, new BasementHelloWorldCommonParts.UA_Processors.MultipleDialogs_Processor.SubDialogAction_ReportUserName {
                userName = newUserName, subDialogID = d2ID
            });
            processor.InvokeUserActions();


            I_UI_DialogWithUser editedSubDlg = TestSettings.Get_UI_DialogWithUser(d2ID);

            //Assert
            Assert.Equal(newUserName, editedSubDlg.strProp_userName);
            Assert.False(editedSubDlg.boolProp_greetingVisible);
            Assert.False(editedSubDlg.boolProp_isActionPossible_TellUserName);
            Assert.True(editedSubDlg.boolProp_helloUserMessageVisible);
            Assert.Equal("helloUserMessage_fr_" + newUserName, editedSubDlg.strProp_helloUserMessageText);
            Assert.True(editedSubDlg.boolProp_isActionPossible_AnswerChatAgainQuestion);
            Assert.Equal("questionForChatingAgain_fr", editedSubDlg.strProp_questionForChatingAgain);
            Assert.Equal("yes_fr", editedSubDlg.strProp_actionExplanation_DoChatAgain);
            Assert.Equal("no_fr", editedSubDlg.strProp_actionExplanation_DontChatAgain);
        }
        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);
                }
            }
        }
Beispiel #17
0
        protected override void Execute(System.Web.Routing.RequestContext requestContext)
        {
            _viewStateManager = new ViewStateManager(requestContext.HttpContext.Request, ViewBag, this.GetViewStateFieldName());
            LoadViewState(_viewStateManager);

            base.Execute(requestContext);
        }
Beispiel #18
0
 protected virtual void SaveViewState(ViewStateManager viewStateManager)
 {
     _viewStateManager.SetViewState("CurrentPage", this.CurrentPage);
     _viewStateManager.SetViewState("TotalRecords", this.TotalRecords);
     _viewStateManager.SetViewState("SearchConditions", this.SearchConditions);
     _viewStateManager.SetViewState("SortConditions", this.SortConditions);
 }
Beispiel #19
0
 protected override object LoadPageStateFromPersistenceMedium()
 {
     return(ViewStateManager.DecompressViewState(this));
 }
Beispiel #20
0
 protected virtual void LoadViewState(ViewStateManager viewStateManager)
 {
     this.CurrentPage = viewStateManager.GetViewState<int>("CurrentPage");
     this.TotalRecords = viewStateManager.GetViewState<int>("TotalRecords");
     this.SearchConditions = viewStateManager.GetViewState<IDictionary<string, string>>("SearchConditions");
     this.SortConditions = viewStateManager.GetViewState<IDictionary<string, string>>("SortConditions");
     if (this.SearchConditions == null)
     {
         this.SearchConditions = new Dictionary<string, string>();
     }
     if (this.SortConditions == null)
     {
         this.SortConditions = new Dictionary<string, string>();
     }
 }
Beispiel #21
0
 protected override void SavePageStateToPersistenceMedium(object viewState)
 {
     ViewStateManager.CompressViewState(this, viewState);
 }
 public MultipleDialogs_Processor Get_MultiDialog_Processor(int viewID)
 {
     return(new MultipleDialogs_Processor(ViewStateManager.getViewFromViewState <Mock_UI_MultipleDialogs>(viewID), new Mock_HelloWorldRepository()));
 }