Esempio n. 1
0
        public void WhenIEnterValidInformationAndSubmitTheSurvey()
        {
            SurveyInput page = ScenarioContext.Current.Get <SurveyInput>("CurrentPage");

            SurveyResult resultPage = page.SubmitWithValidData_ReturnResultsPage();

            ScenarioContext.Current.Set(resultPage, "CurrentPage");
        }
Esempio n. 2
0
        public void GivenIAmOnTheSurveyInputPage()
        {
            SurveyInput page = new SurveyInput(driver);

            page.Navigate();

            ScenarioContext.Current.Set(page, "CurrentPage");
        }
Esempio n. 3
0
        public static Survey Convert(SurveyInput input, int AuthorId)
        {
            var authorRepo = new UserDetailsRepository();
            var Author     = authorRepo.GetById(AuthorId);

            return(new Survey(input.Name, input.StartDate, input.EndDate, input.Description
                              , input.Options.Select(x => OptionInputConverter.Convert(x))
                              , Author, input.PhotoPath, input.Color));
        }
Esempio n. 4
0
        public void SubmitWithValidData_ExpectResultPage()
        {
            SurveyInput page = new SurveyInput(driver);

            page.Navigate();

            SurveyResult result = page.SubmitWithValidData_ReturnResultsPage();

            Assert.IsNotNull(result);
        }
Esempio n. 5
0
        public void SubmitWithInvalidData_ExpectInputPageWithErrors()
        {
            SurveyInput page = new SurveyInput(driver);

            page.Navigate();

            SurveyInput result = page.SubmitWithInvalidData_ReturnToInputPage();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ValidationErrors.Count > 0);
        }
        public async Task <IActionResult> Submit(SurveyInput input)
        {
            var token = HttpContext.Request.Headers["Authorization"].Last().Split(" ").Last();
            var roles = new List <string>()
            {
                "User", "Admin", "SchoolAdmin"
            };
            var handler  = new JwtSecurityTokenHandler();
            var sub      = handler.ReadJwtToken(token).Payload.Sub;
            var surveyId = new UserDetailsRepository().GetByUserId(sub).Id;

            if (RoleService.CheckRoles(token, roles, _userManager))
            {
                var survey = SurveyInputConverter.Convert(input, surveyId);
                _repository.Add(survey);

                return(CreatedAtAction("Submit", survey));
            }
            return(Unauthorized("Only User, Admin, SchoolAdmin have access to this controller."));
        }