コード例 #1
0
        public async Task TestQuestion1SavesCurrentName()
        {
            // Arrange
            var response = SurveyResponse.CreateNew(FakeNow);

            response.Respondent.Name = "Wrong name";
            var clientStorage = Substitute.For <IClientSideStorageService>();
            var dateTime      = Substitute.For <IDateTimeService>();
            var repo          = Substitute.For <ISurveyResponseRepository>();

            var controller = new SurveyController(clientStorage, dateTime, null, null, repo)
            {
                CurrentResponse = response
            };

            var questionAnswer = new NameQuestionViewModel
            {
                Answer = ExcellentName
            };

            // Act
            var result = await controller.Question1(questionAnswer);

            // Assert
            await repo.Received().SaveChanges();

            Assert.IsType <RedirectToActionResult>(result);
            Assert.Equal(ExcellentName, controller.CurrentResponse.Respondent.Name);
        }
コード例 #2
0
        public void TestQuestion1ShowsCurrentName()
        {
            // Arrange
            var response = SurveyResponse.CreateNew(FakeNow);

            response.Respondent.Name = ExcellentName;
            var clientStorage = Substitute.For <IClientSideStorageService>();
            var dateTime      = Substitute.For <IDateTimeService>();
            var repo          = Substitute.For <ISurveyResponseRepository>();

            var controller = new SurveyController(clientStorage, dateTime, null, null, repo)
            {
                CurrentResponse = response
            };

            // Act
            var result = controller.Question1();

            // Assert
            Assert.IsType <ViewResult>(result);
            var viewResult = result as ViewResult;

            Assert.IsType <QuestionPageViewModel <string> >(viewResult.Model);
            var model = viewResult.Model as QuestionPageViewModel <string>;

            Assert.Equal(ExcellentName, model.Question.Answer);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: CRiSTi107/EasySurvey
        private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MaterialMessageInput.MessageBoxResultInput result = MaterialMessageInput.Show("Ce nume are noul chestionar?", "Easy Survey - Add New Survey", MaterialMessageInput.MessageBoxButtonsInput.OKCancel, addSurvey: true);

            if (result == MaterialMessageInput.MessageBoxResultInput.OK)
            {
                using (SurveyController surveyController = new SurveyController())
                {
                    string SurveyName = MaterialMessageInput.Answer;

                    Survey newSurvey = new Survey {
                        SurveyName = SurveyName
                    };
                    surveyController.Add(ref newSurvey);
                    Surveys.Add(newSurvey);
                    ListViewItem newSurveyItem = new ListViewItem(listView_AllSurveys.Groups["default"])
                    {
                        Tag = newSurvey.SurveyID.ToString(), Text = newSurvey.SurveyName
                    };
                    listView_AllSurveys.Items.Add(newSurveyItem);
                    int SurveyIndex = listView_AllSurveys.Items.Count - 1;
                    listView_AllSurveys.Items[SurveyIndex].Selected = true;
                    listView_AllSurveys.Items[SurveyIndex].Focused  = true;
                    listView_AllSurveys.Items[SurveyIndex].EnsureVisible();
                }
            }
        }
コード例 #4
0
        private void btn_Finish_Click(object sender, EventArgs e)
        {
            panel_ConductSurvey.Visible = false;
            panel_ConductSurvey.Enabled = false;
            panel_Finish.Visible        = true;
            panel_Finish.Enabled        = true;

            using (SurveyController surveyController = new SurveyController())
                using (ResultController resultController = new ResultController())
                {
                    string SurveyName = surveyController.Get(SurveyID).SurveyName;
                    string DateNow    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    FinalResult.Date = DateNow;
                    resultController.Add(FinalResult);
                }

            foreach (ResultDefinition resultDefinition in Results)
            {
                resultDefinition.ResultID = FinalResult.ResultID;
            }


            using (ResultDefinitionController resultDefinitionController = new ResultDefinitionController())
                resultDefinitionController.Add(Results);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: CRiSTi107/EasySurvey
        // END - Update All Surveys | Attitudes


        // START - Update Selected Survey | Attitude
        private void UpdateSelectedSurvey(long SurveyID, ListView listView)
        {
            using (SurveyController surveyController = new SurveyController())
            {
                Survey selectedSurvey = surveyController.Get(SurveyID);

                if (LoggedUser.IsAdministrator())
                {
                    txt_EditSurveyDetailsName.Text = selectedSurvey.SurveyName;
                    txt_EditSurveyDetailsName.Tag  = selectedSurvey.SurveyID.ToString();

                    SelectedSurveyOriginalName          = selectedSurvey.SurveyName;
                    IsSelectedSurveyOriginalNameChanged = false;
                }
                else
                {
                    txt_ViewSurveyDetailsName.Text = selectedSurvey.SurveyName;
                    txt_ViewSurveyDetailsName.Tag  = selectedSurvey.SurveyID.ToString();
                }
            }

            listView.Clear();

            using (QuestionController questionController = new QuestionController())
            {
                List <Question> Questions = questionController.GetQuestionsForSurvey(SurveyID);
                foreach (Question question in Questions)
                {
                    listView.Items.Add(new ListViewItem(question.Question1)
                    {
                        Tag = question.QuestionID
                    });
                }
            }
        }
コード例 #6
0
        public async Task SubmitSurvey_InvalidId_ReturnsError()
        {
            var form = new Form
            {
                SurveyId    = "123",
                UserName    = "******",
                ChoicesMade = new Dictionary <string, bool>
                {
                    ["1"] = false,
                    ["2"] = false
                }
            };

            var error          = Error.New($"Survey was not found by {form.SurveyId}");
            var mockRepository = Substitute.For <ISurveyRepository>();

            mockRepository.SubmitSurveyAsync(form).Returns(error);

            var controller = new SurveyController(mockRepository);

            var response = await controller.SubmitSurvey(form);

            response.Should().NotBeNull();
            response.Should().BeOfType <ObjectResult>()
            .Which.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);

            var ok = response as ObjectResult;

            ok.Value.Should().BeAssignableTo <Error>();
            ok.Value.Should().BeEquivalentTo(error, opt => opt.IgnoringCyclicReferences());

            await mockRepository.Received().SubmitSurveyAsync(form);
        }
コード例 #7
0
ファイル: SurveyControllerTest.cs プロジェクト: tevert/Mood
        public void Get_IdOK_ReturnsViewWithMoods()
        {
            var id     = Guid.NewGuid();
            var survey = new Survey()
            {
                Id = id, Description = "test survey"
            };
            var moods = new List <Models.Mood>()
            {
                new Models.Mood(), new Models.Mood()
            };

            var surveysMock = new Mock <ISurveyService>();

            surveysMock.Setup(s => s.FindAsync(id.ToString())).ReturnsAsync(survey);

            var dbMock       = new Mock <IApplicationDBContext>();
            var moodDataMock = new Mock <DbSet <Models.Mood> >().SetupData(moods);

            dbMock.Setup(db => db.Moods).Returns(moodDataMock.Object);

            var subject = new SurveyController(dbMock.Object, surveysMock.Object, Mock.Of <ISecurity>());

            var result = subject.Get(id.ToString()).Result;

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreSame(survey, ((result as ViewResult).Model as SurveyViewModel).Survey);
            Assert.AreEqual(2, ((result as ViewResult).Model as SurveyViewModel).Moods.Count());
        }
コード例 #8
0
        public async Task SubmitSurvey_ValidId_ReturnsOk()
        {
            var survey = RandomEntitiesGenerator.PredefinedSurveys.First();
            var form   = new Form
            {
                SurveyId    = survey.Id,
                UserName    = "******",
                ChoicesMade = new Dictionary <string, bool>
                {
                    ["1"] = false,
                    ["2"] = false
                }
            };

            var mockRepository = Substitute.For <ISurveyRepository>();

            mockRepository.SubmitSurveyAsync(form).Returns(form);

            var controller = new SurveyController(mockRepository);

            var response = await controller.SubmitSurvey(form);

            response.Should().NotBeNull();
            response.Should().BeOfType <OkObjectResult>()
            .Which.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var ok = response as OkObjectResult;

            ok.Value.Should().BeAssignableTo <Form>();
            ok.Value.Should().BeEquivalentTo(form, opt => opt.IgnoringCyclicReferences());

            await mockRepository.Received().SubmitSurveyAsync(form);
        }
コード例 #9
0
ファイル: SurveyControllerTest.cs プロジェクト: tevert/Mood
        public void Edit_ServiceException_ReturnsErrorJson()
        {
            var id     = Guid.NewGuid();
            var survey = new Survey()
            {
                Id = id, Owner = new ApplicationUser()
                {
                    UserName = "******"
                }
            };
            var newData = new SurveyEditViewModel()
            {
            };
            var error = "Bad data!";

            var dbMock = new Mock <IApplicationDBContext>();

            var surveysMock = new Mock <ISurveyService>();

            surveysMock.Setup(s => s.FindAsync(id.ToString())).ReturnsAsync(survey);
            surveysMock.Setup(s => s.EditAsync(survey, newData)).Throws(new SurveyException(error));

            var securityMock = new Mock <ISecurity>();

            securityMock.SetupGet(s => s.UserName).Returns("Tyler");

            var subject = new SurveyController(dbMock.Object, surveysMock.Object, securityMock.Object);

            var result = subject.Edit(id.ToString(), newData).Result;

            Assert.IsInstanceOfType(result, typeof(JsonResult));
            dynamic jsonData = (result as JsonResult).Data;

            Assert.AreEqual(error, jsonData.error);
        }
コード例 #10
0
ファイル: SurveyControllerTest.cs プロジェクト: tevert/Mood
        public void Edit_ServiceOK_ReturnsSuccessJson()
        {
            var id     = Guid.NewGuid();
            var survey = new Survey()
            {
                Id = id, Owner = new ApplicationUser()
                {
                    UserName = "******"
                }
            };
            var newData = new SurveyEditViewModel()
            {
            };

            var dbMock = new Mock <IApplicationDBContext>();

            var surveysMock = new Mock <ISurveyService>();

            surveysMock.Setup(s => s.FindAsync(id.ToString())).ReturnsAsync(survey);

            var securityMock = new Mock <ISecurity>();

            securityMock.SetupGet(s => s.UserName).Returns("Tyler");

            var subject = new SurveyController(dbMock.Object, surveysMock.Object, securityMock.Object);

            var result = subject.Edit(id.ToString(), newData).Result;

            surveysMock.Verify(s => s.EditAsync(survey, newData));
            Assert.IsInstanceOfType(result, typeof(JsonResult));
            dynamic jsonData = (result as JsonResult).Data;

            Assert.IsNotNull(jsonData.success);
        }
コード例 #11
0
ファイル: SurveyControllerTest.cs プロジェクト: tevert/Mood
        public void Delete_IdOK_DeletesAnswersAndDeletesSurveyAndRedirectsToHome()
        {
            var id     = Guid.NewGuid();
            var survey = new Survey()
            {
                Id = id, Owner = new ApplicationUser()
                {
                    UserName = "******"
                }
            };

            var surveysMock = new Mock <ISurveyService>();

            surveysMock.Setup(s => s.FindAsync(id.ToString())).ReturnsAsync(survey);

            var dbMock = new Mock <IApplicationDBContext>();

            var securityMock = new Mock <ISecurity>();

            securityMock.SetupGet(s => s.UserName).Returns("Tyler");

            var subject = new SurveyController(dbMock.Object, surveysMock.Object, securityMock.Object);

            var result = subject.Delete(id.ToString()).Result;

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            surveysMock.Verify(d => d.DeleteAsync(survey));
        }
コード例 #12
0
ファイル: SurveyControllerTest.cs プロジェクト: tevert/Mood
        public void Edit_WrongUser_Returns403()
        {
            var id     = Guid.NewGuid();
            var survey = new Survey()
            {
                Id = id, Owner = new ApplicationUser()
                {
                    UserName = "******"
                }
            };

            var dbMock = new Mock <IApplicationDBContext>();

            var surveysMock = new Mock <ISurveyService>();

            surveysMock.Setup(s => s.FindAsync(id.ToString())).ReturnsAsync(survey);

            var securityMock = new Mock <ISecurity>();

            securityMock.SetupGet(s => s.UserName).Returns("Peter");

            var subject = new SurveyController(dbMock.Object, surveysMock.Object, securityMock.Object);

            var result = subject.Edit(id.ToString(), new SurveyEditViewModel()).Result;

            Assert.IsInstanceOfType(result, typeof(HttpStatusCodeResult));
            Assert.AreEqual(403, (result as HttpStatusCodeResult).StatusCode);
        }
コード例 #13
0
        public async void AddOuestionToSurvey_ValidObjectPassed_ReturnsAllItems()
        {
            // Arrange
            var mock = new Mock <ISurveyService>();

            mock.Setup(s => s.AddQuestionToSurveyAsync(It.IsAny <int>(), It.IsAny <QuestionDTO>())).Returns((int id, QuestionDTO s) => FakeServicesMethods.AddQuestionToSurvey(id, s));
            var controller = new SurveyController(mock.Object);

            // Act
            var question = new QuestionDTO
            {
                Id           = 1,
                Title        = "Question 1",
                QuestionText = "text",
                Comment      = "",
                Answers      = new List <AnswerDTO>()
            };
            var result = await controller.AddOuestionToSurvey(1, question);

            var okResult = result as OkObjectResult;

            // Assert
            Assert.NotNull(okResult);
            Assert.Equal(1, (okResult.Value as SurveyDTO)?.Questions.Count);
        }
コード例 #14
0
        public async void ChangeSurvey_ValidObjectPassed_ReturnedResponseHaUpdatedItem()
        {
            // Arrange
            var mock = new Mock <ISurveyService>();

            mock.Setup(s => s.UpdateAsync(It.IsAny <int>(), It.IsAny <SurveyDTO>())).Returns((int id, SurveyDTO s) => FakeServicesMethods.ChangeSurvey(id, s));
            var controller = new SurveyController(mock.Object);

            // Act
            var survey = new SurveyDTO
            {
                Id        = 1,
                Creator   = "John",
                Date      = DateTime.Now,
                Views     = 3,
                Title     = "Survey 1",
                Questions = new List <QuestionDTO>()
            };
            var result = await controller.ChangeSurvey(1, survey);

            var okResult = result as OkObjectResult;

            // Assert
            var item = Assert.IsAssignableFrom <SurveyDTO>(okResult.Value);

            Assert.Equal(1, (okResult.Value as SurveyDTO)?.Id);
        }
コード例 #15
0
        public async void ChangeSurvey_ValidObjectPassed_ReturnsOk()
        {
            // Arrange
            var mock = new Mock <ISurveyService>();

            mock.Setup(s => s.UpdateAsync(It.IsAny <int>(), It.IsAny <SurveyDTO>())).Returns((int id, SurveyDTO s) => FakeServicesMethods.ChangeSurvey(id, s));
            var controller = new SurveyController(mock.Object);

            // Act
            var survey = new SurveyDTO
            {
                Id        = 1,
                Creator   = "John",
                Date      = DateTime.Now,
                Views     = 3,
                Title     = "Survey 1",
                Questions = new List <QuestionDTO>()
            };
            var result = await controller.ChangeSurvey(1, survey);

            var okResult = result as OkObjectResult;

            // Assert
            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);
        }
コード例 #16
0
        public WhenCallingGetOnSurveyController()
        {
            var repo = new MockRepository(MockBehavior.Default);

            _mockConsoleAdapter = repo.Create <IConsoleAdapter>();
            _surveyController   = new SurveyController(_mockConsoleAdapter.Object);
        }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: CRiSTi107/EasySurvey
        private void pic_SaveChanges_Click(object sender, EventArgs e)
        {
            if (IsSelectedSurveyOriginalNameChanged)
            {
                long   SurveyID      = Convert.ToInt64(txt_EditSurveyDetailsName.Tag.ToString());
                string NewSurveyName = txt_EditSurveyDetailsName.Text;

                using (SurveyController surveyController = new SurveyController())
                    surveyController.UpdateSurveyName(SurveyID, NewSurveyName);

                int SurveyListItemIndex = -1;
                foreach (ListViewItem SurveyListItem in listView_AllSurveys.SelectedItems)
                {
                    if (Convert.ToInt64(SurveyListItem.Tag.ToString()) == SurveyID)
                    {
                        SurveyListItemIndex = listView_AllSurveys.Items.IndexOf(SurveyListItem);
                        Surveys.Where(item => item.SurveyID == SurveyID).ToList().ForEach(item => item.SurveyName = NewSurveyName);
                        listView_AllSurveys.Items[SurveyListItemIndex].Text = NewSurveyName;
                    }
                }

                SelectedSurveyOriginalName            = NewSurveyName;
                IsSelectedSurveyOriginalNameChanged   = false;
                pic_SaveSurveyChanges.BackgroundImage = Properties.Resources.save_icon_disabled_24x24;
                pic_SaveSurveyChanges.Cursor          = Cursors.Arrow;
            }
        }
 public WebAPISurveyControllerTests()
 {
     _surveyStore             = new Mock <ISurveyStore>();
     _contributorRequestStore = new Mock <IContributorRequestStore>();
     _authorizationService    = new Mock <IAuthorizationService>();
     _target = new SurveyController(_surveyStore.Object, _contributorRequestStore.Object, _authorizationService.Object);
 }
コード例 #19
0
        public SurveyControllerTest()
        {
            var mappingConfig = new MapperConfiguration(mc => mc.AddProfile(new MappingProfile()));
            var mapper        = mappingConfig.CreateMapper();

            _controller = new SurveyController(new TestApplicationContext(), mapper);
        }
コード例 #20
0
        public void ListAction_WhenSurveyCompleted_ExpectPost()
        {
            //Arrange
            var fakeComplete = new List <SurveyModel>()
            {
                new SurveyModel {
                    ParkCode = "CVNP", EmailAddress = "*****@*****.**", PhysicalActivityLevel = "Sedentary", StateOfResidence = "Alabama", NumberOfVotes = 2
                },
                new SurveyModel {
                    ParkCode = "GTNP", EmailAddress = "*****@*****.**", PhysicalActivityLevel = "Inactive", StateOfResidence = "Illinois", NumberOfVotes = 4
                }
            };
            // Mock the dal
            Mock <ISurveyDAL> mockDal = new Mock <ISurveyDAL>();

            //Set up the mock object
            mockDal.Setup(s => s.GetAllSurveys()).Returns(fakeComplete);

            SurveyController controller = new SurveyController(mockDal.Object);

            //Act
            var result = controller.DisplaySurvey() as ViewResult;

            //Assert
            Assert.AreEqual("DisplaySurvey", result.ViewName);
            Assert.IsNotNull(result.Model);
        }
        public void TestSurveyResults()
        {
            // Arrange
            ParkMockDAO      parkDAO    = new ParkMockDAO();
            SurveyMockDAO    surveyDAO  = new SurveyMockDAO();
            SurveyController controller = new SurveyController(parkDAO, surveyDAO);

            // Act
            Survey newSurvey = new Survey()
            {
                ParkCode         = "YOSE",
                Email            = "*****@*****.**",
                ActivityLevel    = "Active",
                StateOfResidence = "California",
            };

            surveyDAO.SaveSurvey(newSurvey);
            IActionResult result = controller.SurveyResults();

            // Assert
            ViewResult vr = result as ViewResult;

            Assert.IsNotNull(vr, "SurveyResults did not return a View");

            IList <SurveyResult> surveyResults = vr.Model as IList <SurveyResult>;

            Assert.IsNotNull(surveyResults, "ViewResult.Model is not an IList<SurveyResult>");
            Assert.AreEqual(4, surveyResults.Count);
        }
コード例 #22
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //  home = new HomeController();
            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // If you have defined a view, add it here:
            // window.RootViewController  = rootNavController;

            //var controller = new UIViewController();
            //controller.View.BackgroundColor = UIColor.Gray;


            //Creating custom controller
            customController = new SurveyController();

            //adding it to navigation controller
            UINavigationController rootNavController = new UINavigationController();

            rootNavController.PushViewController(customController, false);

            window.RootViewController = rootNavController;
            // make the window visible
            window.MakeKeyAndVisible();

            return(true);
        }
コード例 #23
0
 public WebAPISurveyControllerTests()
 {
     _surveyStore             = A.Fake <ISurveyStore>();
     _contributorRequestStore = A.Fake <IContributorRequestStore>();
     _authorizationService    = A.Fake <IAuthorizationService>();
     _target = new SurveyController(_surveyStore, _contributorRequestStore, _authorizationService);
 }
コード例 #24
0
ファイル: UnitTest.cs プロジェクト: jbebe/SurveyGorilla
        public void TestSurvey()
        {
            var survey = new List <SurveyEntity>
            {
                new SurveyEntity {
                    Id = 1, Info = "{}"
                },
                new SurveyEntity {
                    Id = 2, Info = "{}"
                },
                new SurveyEntity {
                    Id = 3, Info = "{}"
                }
            }.AsQueryable();

            var mockSet = new Mock <DbSet <SurveyEntity> >();

            mockSet.As <IQueryable <SurveyEntity> >().Setup(m => m.Provider).Returns(survey.Provider);
            mockSet.As <IQueryable <SurveyEntity> >().Setup(m => m.Expression).Returns(survey.Expression);
            mockSet.As <IQueryable <SurveyEntity> >().Setup(m => m.ElementType).Returns(survey.ElementType);
            mockSet.As <IQueryable <SurveyEntity> >().Setup(m => m.GetEnumerator()).Returns(() => survey.GetEnumerator());

            var mockContext = new Mock <SurveyContext>();

            mockContext.Setup(c => c.Surveys).Returns(mockSet.Object);

            var controller = new SurveyController(mockContext.Object);

            var result = controller.GetSurveys() as List <SurveyEntity>;

            Assert.AreEqual(1, result.Count);
        }
コード例 #25
0
        public async Task SaveResponse_ValidModel_SavesResponse()
        {
            Mock <ISurveyResponses> mockSurveyResponse = new Mock <ISurveyResponses>();

            SurveyController surveyController = new SurveyController();
            HttpContext      context          = new DefaultHttpContext();

            surveyController.TempData = new TempDataDictionary(new DefaultHttpContext(), new Mock <ITempDataProvider>().Object);

            SummaryModel       summaryModel       = new SummaryModel();
            NameModel          nameModel          = new NameModel();
            EmailModel         emailModel         = new EmailModel();
            AddressModel       addressModel       = new AddressModel();
            LightingLevelModel lightingLevelModel = new LightingLevelModel();

            lightingLevelModel.HappyWithLightingLevel = true;
            BrightnessModel brightnessModel = new BrightnessModel();

            brightnessModel.BrightnessLevel = 5;

            summaryModel.Name          = nameModel;
            summaryModel.Email         = emailModel;
            summaryModel.Address       = addressModel;
            summaryModel.LightingLevel = lightingLevelModel;
            summaryModel.Brightness    = brightnessModel;

            RedirectToActionResult result = (RedirectToActionResult)await surveyController.SaveResponse(mockSurveyResponse.Object, summaryModel);

            Assert.IsNotNull(result);
            Assert.AreEqual("Confirmation", result.ActionName);

            mockSurveyResponse.Verify(s => s.SaveSurveyResponse(It.IsAny <LightingSurvey>()), Times.Once);
        }
コード例 #26
0
ファイル: AppDelegate.cs プロジェクト: agholap/Survey
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //  home = new HomeController();
            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // If you have defined a view, add it here:
            // window.RootViewController  = rootNavController;

            //var controller = new UIViewController();
            //controller.View.BackgroundColor = UIColor.Gray;

            //Creating custom controller
            customController = new SurveyController();

            //adding it to navigation controller
            UINavigationController rootNavController = new UINavigationController();
            rootNavController.PushViewController(customController, false);

            window.RootViewController  = rootNavController;
            // make the window visible
            window.MakeKeyAndVisible();

            return true;
        }
コード例 #27
0
        public void Survey_HttpGet_ReturnsCorrectView()
        {
            SurveyController Controller = new SurveyController();
            ViewResult       result     = Controller.Survey() as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Survey", result.ViewName);
        }
コード例 #28
0
 public SpeechInfo(string speechScript, SurveyController webSurvey)
 {
     this.speechScript   = speechScript;
     this.webSurvey      = webSurvey;
     shouldGoNext        = CheckShouldGoNextStep(speechScript);
     shouldWaitForAnswer = CheckShouldWaitForAnswer(speechScript);
     contentState        = CheckContentState(speechScript);
 }
コード例 #29
0
        public void SetUp()
        {
            var mock = new Mock <ILogger <SurveyController> >();

            _logger           = mock.Object;
            _surveyService    = new MockSurveyService();
            _surveyController = new SurveyController(_surveyService, _logger);
        }
コード例 #30
0
        public void Getsurvey_ShouldNotFindsurvey()
        {
            var controller = new SurveyController(GetTestSurvey());

            var result = controller.GetSurvey(3);

            Assert.IsInstanceOfType(result, typeof(Activity));
        }
コード例 #31
0
        public void Confirmation_HttpGet_ReturnsCorrectView()
        {
            SurveyController controller = new SurveyController(null);

            ViewResult result = controller.Confirmation() as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Confirmation", result.ViewName);
        }
コード例 #32
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            SurveyContext sc = new SurveyContext();
            SurveyResult result = new SurveyResult();
            sc._SurveyResult = result;

            SurveyController controller = new SurveyController(sc);
            controller.Return += new ReturnEventHandler<SurveyResult>(controller_Return);
            NavigationService.Navigate(controller);
        }