コード例 #1
0
        public void TestGetAsync_SearchValue_ReturnsRespondentSurveys()
        {
            const string searchValue        = "*****@*****.**";
            const string encodedSearchValue = "email%40nipo.com";

            var expectedSurvey = new SurveyBase
            {
                SurveyId   = SurveyId,
                SurveyName = SurveyName
            };

            var expectedResult = new List <SurveyBase> {
                expectedSurvey
            };

            _mockedHttpClient
            .Setup(client => client.GetAsync(new Uri(ServiceAddress, $"Surveys/Search?value={encodedSearchValue}")))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedResult))));

            var result = _target.GetAsync(searchValue).Result;

            Assert.NotNull(result);
            Assert.True(result.Any());
            Assert.Equal(expectedSurvey.SurveyId, result.First().SurveyId);
            Assert.Equal(expectedSurvey.SurveyName, result.First().SurveyName);
        }
コード例 #2
0
        public void TestGetAsync_SearchValueWithSpecialCharacters_ReturnsRespondentSurveys()
        {
            const string searchValue        = @";/?:@=&$-_.+!*'(),";
            const string encodedSearchValue = @"%3b%2f%3f%3a%40%3d%26%24-_.%2b!*%27()%2c";

            var expectedSurvey = new SurveyBase
            {
                SurveyId   = SurveyId,
                SurveyName = SurveyName
            };

            var expectedResult = new List <SurveyBase> {
                expectedSurvey
            };

            _mockedHttpClient
            .Setup(client => client.GetAsync(new Uri(ServiceAddress, $"Surveys/Search?value={encodedSearchValue}")))
            .Returns(CreateTask(HttpStatusCode.OK, new StringContent(JsonConvert.SerializeObject(expectedResult))));

            var result = _target.GetAsync(searchValue).Result;

            Assert.NotNull(result);
            Assert.True(result.Any());
            Assert.Equal(expectedSurvey.SurveyId, result.First().SurveyId);
            Assert.Equal(expectedSurvey.SurveyName, result.First().SurveyName);
        }
コード例 #3
0
        public void GetSurveyInfo(string Id)
        {
            //浏览量+1
            surveyBaseBLL.PlusOne(Id, OperatType.PV);
            string stateText = "";
            var    readrows  = messageReadBLL.GetList(OperatorProvider.Provider.Current().UserId).Where(t => t.Category == surveyCategory && t.MessageId.Equals(Id)).FirstOrDefault();;

            if (readrows == null)
            {
                stateText = "未读";
            }
            else if (readrows.AppRead && readrows.SubmitMark)
            {
                stateText = "已读已完成";
            }
            else if (readrows.AppRead && !readrows.SubmitMark)
            {
                stateText = "已读未完成";
            }
            else
            {
                stateText = "已读未完成";
            }
            SurveyBaseEntity            surveyBaseEntity     = new SurveyBaseEntity();
            List <SurveyQuestionEntity> surveyQuestionEntity = new List <SurveyQuestionEntity>();
            List <SurveyOptionsEntity>  surveyOptionsEntity  = new List <SurveyOptionsEntity>();

            //答案选项
            SurveyAnswerBaseEntity          surveyAnswerBaseEntity   = new SurveyAnswerBaseEntity();
            List <SurveyAnswerDetailEntity> surveyAnswerDetailEntity = new List <SurveyAnswerDetailEntity>();

            SurveyBase surveyInfo = new SurveyBase();

            surveyBaseEntity     = surveyBaseBLL.GetEntity(Id);
            surveyQuestionEntity = surveyQuestionBLL.GetList(Id);//.OrderBy(t => t.SortCode).ToList();
            surveyOptionsEntity  = surveyOptionsBLL.GetList(Id);
            //答案选项
            surveyAnswerBaseEntity = surveyAnswerBaseBLL.GetList().Where(t => t.UserId == OperatorProvider.Provider.Current().UserId&& t.SurveyId == Id).FirstOrDefault();
            if (surveyAnswerBaseEntity != null && !string.IsNullOrWhiteSpace(surveyAnswerBaseEntity.Id))
            {
                surveyAnswerDetailEntity = surveyAnswerDetailBLL.GetList(surveyAnswerBaseEntity.Id);
            }

            //赋值
            surveyInfo.Id         = surveyBaseEntity.Id;
            surveyInfo.Category   = surveyBaseEntity.Category;
            surveyInfo.CreateDate = surveyBaseEntity.CreateDate;

            surveyInfo.Title              = surveyBaseEntity.Title;
            surveyInfo.TitleColor         = surveyBaseEntity.TitleColor;
            surveyInfo.OperateSDate       = surveyBaseEntity.OperateSDate;
            surveyInfo.OperateEDate       = surveyBaseEntity.OperateEDate;
            surveyInfo.JoinCount          = surveyBaseEntity.JoinCount;
            surveyInfo.PV                 = surveyBaseEntity.PV;
            surveyInfo.SurveyQuestionList = new List <SurveyQuestion>();
            for (int i = 0; i < surveyQuestionEntity.Count; i++)
            {
                SurveyQuestion surveyQuestion = new SurveyQuestion();
                surveyQuestion.QuestionId = surveyQuestionEntity[i].QuestionId;
                surveyQuestion.Category   = surveyQuestionEntity[i].Category;
                surveyQuestion.Title      = surveyQuestionEntity[i].Title;
                surveyQuestion.CreateDate = surveyQuestionEntity[i].CreateDate;
                surveyQuestion.Score      = surveyQuestionEntity[i].Score;
                surveyQuestion.SortCode   = surveyQuestionEntity[i].SortCode;
                surveyQuestion.SurveyId   = surveyQuestionEntity[i].SurveyId;
                if (surveyQuestion.Category == "7")
                {
                    surveyQuestion.Content = surveyAnswerDetailEntity.Where(t => t.QuestionId == surveyQuestion.QuestionId).FirstOrDefault().Content;
                }
                surveyQuestion.SurveyOptionsList = new List <SurveyOptions>();
                var surveyOptionsList = surveyOptionsEntity.Where(t => t.QuestionId == surveyQuestionEntity[i].QuestionId).ToList();
                if (surveyOptionsList.Count > 0)
                {
                    for (int k = 0; k < surveyOptionsList.Count; k++)
                    {
                        SurveyOptions surveyOptions = new SurveyOptions();
                        surveyOptions.OptionId   = surveyOptionsList[k].OptionId;
                        surveyOptions.SurveyId   = surveyOptionsList[k].SurveyId;
                        surveyOptions.QuestionId = surveyOptionsList[k].QuestionId;
                        surveyOptions.SortCode   = surveyOptionsList[k].SortCode;
                        surveyOptions.Content    = surveyOptionsList[k].Content;
                        surveyOptions.CreateDate = surveyOptionsList[k].CreateDate;
                        surveyOptions.Category   = surveyOptionsList[k].Category;
                        surveyOptions.IsAnswer   = false;
                        if (surveyQuestion.Category == "1" || surveyQuestion.Category == "2")
                        {
                            surveyOptions.IsAnswer = surveyAnswerDetailEntity.Where(t => t.OptionId == surveyOptions.OptionId).ToList().Count > 0 ? true : false;;
                        }
                        surveyQuestion.SurveyOptionsList.Add(surveyOptions);
                    }
                }
                surveyInfo.SurveyQuestionList.Add(surveyQuestion);
            }
            ViewBag.stateText  = stateText;
            ViewBag.SurveyBase = surveyInfo;
        }
コード例 #4
0
 public void CreateSurvey(string surveyTitle, SurveyUser userCreator)
 {
     survey = new SurveyBase(surveyTitle);
 }