public void GenerateWithScoreTest() { int id, dboResult; Object expected, actual; DateTime now, startTime; ExaminationTask et; UExaminationTask uet; GeneratePaperTemplate_Accessor target = new GeneratePaperTemplate_Accessor(); List<Question> qs; actual = null; // 备选试题总分小于出题总分 #region 部署测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; dboResult = olsDbo.ExecuteSql("UPDATE Questions SET Q_Status = @status", new SqlParameter("@status", (Byte)Status.Recycle)); if (0 == dboResult) { Assert.Fail("更新试题数据失败。"); } qs = olsEni.Questions.Where(m => m.Q_Type == "单选题").Take(1).ToList(); qs.AddRange(olsEni.Questions.Where(m => m.Q_Type == "多选题").Take(1).ToList()); qs.AddRange(olsEni.Questions.Where(m => m.Q_Type == "判断题").Take(1).ToList()); qs.AddRange(olsEni.Questions.Where(m => m.Q_Type == "公文改错题").Take(1).ToList()); qs.AddRange(olsEni.Questions.Where(m => m.Q_Type == "计算题").Take(1).ToList()); qs.AddRange(olsEni.Questions.Where(m => m.Q_Type == "案例分析题").Take(1).ToList()); qs.AddRange(olsEni.Questions.Where(m => m.Q_Type == "问答题").Take(1).ToList()); foreach (var q in qs) { q.Q_Status = (Byte)Status.Available; } if (0 == olsEni.SaveChanges()) { Assert.Fail("部署测试数据失败。"); } #endregion expected = "备选试题总分小于出题总分。"; try { target.GenerateWithScore(et); } catch (Exception ex) { actual = ex; } Assert.AreEqual(expected, ((Exception)actual).Message); actual = null; #region 恢复试题状态 dboResult = olsDbo.ExecuteSql("UPDATE Questions SET Q_Status = @status", new SqlParameter("@status", (Byte)Status.Available)); if (0 == dboResult) { Assert.Fail("更新试题数据失败。"); } #endregion // 备选试题总分大于出题总分 #region 部署测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; if (0 == olsEni.SaveChanges()) { Assert.Fail("部署测试数据失败。"); } #endregion expected = et.ET_TotalScore; actual = target.GenerateWithScore(et); Assert.AreEqual(expected, ((List<Question>)actual).Sum(m => m.Q_Score)); }
public void GenerateTest() { int id, dboResult; Object expected, actual; DateTime now, startTime; ExaminationTask et; UExaminationTask uet; GeneratePaperTemplate_Accessor target = new GeneratePaperTemplate_Accessor(); actual = null; #region 部署测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; if (0 == olsEni.SaveChanges()) { Assert.Fail("添加测试数据失败。"); } dboResult = olsDbo.ExecuteSql("UPDATE Questions SET Q_Status = @status", new SqlParameter("@status", (Byte)Status.Recycle)); if (0 == dboResult) { Assert.Fail("更新试题数据失败。"); } #endregion expected = "单元测试每日任务1:备选试题总分小于出题总分。\\r\\n"; actual = target.Generate(); Assert.AreEqual(expected, ((ResponseJson)actual).message); actual = null; #region 恢复试题数据 dboResult = olsDbo.ExecuteSql("UPDATE Questions SET Q_Status = @status", new SqlParameter("@status", (Byte)Status.Available)); if (0 == dboResult) { Assert.Fail("更新试题数据失败。"); } #endregion // 正常情况 #region 部署测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; if (0 == olsEni.SaveChanges()) { Assert.Fail("添加测试数据失败。"); } dboResult = olsDbo.ExecuteSql("UPDATE Questions SET Q_Status = @status", new SqlParameter("@status", (Byte)Status.Available)); if (0 == dboResult) { Assert.Fail("更新试题数据失败。"); } #endregion expected = "成功处理 1个考试任务。"; actual = target.Generate(); Assert.AreEqual(expected, ((ResponseJson)actual).addition); actual = null; }
public void GenerateEtTest() { int id; Object expected, actual; DateTime now, startTime; ExaminationTask et; UExaminationTask uet; GeneratePaperTemplate_Accessor target = new GeneratePaperTemplate_Accessor(); actual = null; // 成绩计算方式为得分 #region 添加测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; #endregion expected = et.ET_TotalScore; actual = target.Generate(et); Assert.AreEqual(expected, ((List<Question>)actual).Sum(m => m.Q_Score)); actual = null; // 成绩计算方式为正确率 #region 添加测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Number, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; #endregion expected = et.ET_TotalNumber; actual = target.Generate(et); Assert.AreEqual(expected, ((List<Question>)actual).Count); actual = null; // 未设置成绩计算方式 #region 添加测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Unset, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; #endregion expected = "未设置成绩计算方式。任务Id:"+ et.ET_Id; try { target.Generate(et); } catch (Exception ex) { actual = ex; } Assert.AreEqual(expected, ((Exception)actual).Message + ((Exception)actual).Data["Info"]); actual = null; }
public void WhetherGenerateTest3_1() { int id; bool expected, actual; DateTime now, startTime; ExaminationTask et; UExaminationTask uet; GeneratePaperTemplate_Accessor target = new GeneratePaperTemplate_Accessor(); #region 添加测试数据 now = DateTime.Now; startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); uet = new UExaminationTask(); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每月任务1", ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Month, ET_AutoOffsetDay = 1, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; if (0 == olsEni.SaveChanges()) { Assert.Fail("添加测试数据失败。"); } #endregion expected = false; actual = target.WhetherGenerate(et); #region 删除测试数据 olsEni.Entry(et).State = EntityState.Deleted; if (0 == olsEni.SaveChanges()) { Assert.Fail("删除测试数据失败。id值为 " + id + " 。"); } #endregion Assert.AreEqual(expected, actual); }
public void ChangeTest1() { int id; DateTime now, startTime; ExaminationTask et; ExaminationPaperTemplate ept; UExaminationTask uet; GeneratePaperTemplate_Accessor gpt = new GeneratePaperTemplate_Accessor(); ChangePaperTemplateStatus target; ResponseJson resJson; Object expected, actual; // 获取状态为“未做”、“进行中”的试卷模板 #region 部署测试数据 now = DateTime.Now; uet = new UExaminationTask(); startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务" + id, ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; startTime = new DateTime(1970, 1, 1, now.Hour, now.Minute, now.AddSeconds(5).Second); id += 1; et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务" + id, ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0.1},{\"type\":\"计算题\",\"percent\":0.1},{\"type\":\"案例分析题\",\"percent\":0.1},{\"type\":\"问答题\",\"percent\":0.1}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; if (0 == olsEni.SaveChanges()) { Assert.Fail("部署测试数据失败1。"); } // 生成试卷模板数据 uet = new UExaminationTask(); resJson = gpt.Generate(); if (ResponseStatus.Error == resJson.status || resJson.message != "") { Assert.Fail("部署测试数据失败3。" + resJson.message); } Thread.Sleep(10 * 1000); ept = olsEni.ExaminationPaperTemplates.SingleOrDefault(m => m.ET_Id == id); if (null == ept) { Assert.Fail("部署测试数据失败4。"); } ept.EPT_PaperTemplateStatus = (Byte)PaperTemplateStatus.Doing; if (0 == olsEni.SaveChanges()) { Assert.Fail("部署测试数据失败2。"); } #endregion expected = "共有 2条记录。其中“未做” 1条;“进行中” 1条。"; target = new ChangePaperTemplateStatus(); actual = target.Change(); Assert.AreEqual(expected, ((Dictionary<String, String>)(((ResponseJson)actual).data))["RecordInfo"]); }
public void ChangeTest() { Int32 id, epId, epqId; DateTime now, startTime; ExaminationTask et; ExaminationPaperTemplate ept; UExaminationTask uet; GeneratePaperTemplate_Accessor gpt = new GeneratePaperTemplate_Accessor(); ChangePaperStatus target = new ChangePaperStatus(); ResponseJson resJson; ExaminationPaper ep; ExaminationPaperQuestion epq; Object expected, actual; List<ExaminationPaperTemplateQuestion> eptqs; #region 部署测试数据 now = DateTime.Now; uet = new UExaminationTask(); startTime = new DateTime(1970, 1, 1, now.AddHours(1).Hour, now.Minute, 0); id = new Utility().GetETId(); et = new ExaminationTask { ET_Id = id, ET_Name = "单元测试每日任务" + id, ET_Enabled = (Byte)ExaminationTaskStatus.Enabled, ET_Type = (Byte)ExaminationTaskType.Examination, ET_ParticipatingDepartment = "[6,9]", ET_Attendee = "[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,39,40,41,42,43,44,45]", ET_StatisticType = (Byte)StatisticType.Score, ET_TotalScore = 100, ET_TotalNumber = 10, ET_Mode = (Byte)ExaminationTaskMode.Auto, ET_AutoType = (Byte)AutoType.Day, ET_AutoOffsetDay = 0, ET_DifficultyCoefficient = 0, ET_AutoClassifies = "[\"综合、公文、绩效知识(90题)\",\"所得税知识(180题)\",\"营业税知识(60题)\",\"其他地方税知识(180题)\",\"税收征管法、相关法律法规及征管制度(253题)\",\"规费知识(130题)\",\"纳税服务知识(95题)\"]", ET_AutoRatio = "[{\"type\":\"单选题\",\"percent\":0.2},{\"type\":\"多选题\",\"percent\":0.2},{\"type\":\"判断题\",\"percent\":0.2},{\"type\":\"公文改错题\",\"percent\":0},{\"type\":\"计算题\",\"percent\":0},{\"type\":\"案例分析题\",\"percent\":0},{\"type\":\"问答题\",\"percent\":0}]", ET_StartTime = startTime, ET_EndTime = startTime, ET_TimeSpan = 0, ET_PaperTemplates = "[]", ET_Questions = "[]", ET_Remark = "", ET_AddTime = now, ET_Status = (Byte)Status.Available }; olsEni.Entry(et).State = EntityState.Added; if (0 == olsEni.SaveChanges()) { Assert.Fail("部署测试数据失败1。"); } // 生成试卷模板数据 uet = new UExaminationTask(); resJson = gpt.Generate(); if (ResponseStatus.Error == resJson.status || resJson.message != "") { Assert.Fail("部署测试数据失败3。" + resJson.message); } Thread.Sleep(10 * 1000); ept = olsEni.ExaminationPaperTemplates.SingleOrDefault(m => m.ET_Id == id); if (null == ept) { Assert.Fail("部署测试数据失败4。"); } ept.EPT_PaperTemplateStatus = (Byte)PaperTemplateStatus.Done; if (0 == olsEni.SaveChanges()) { Assert.Fail("部署测试数据失败2。"); } // 添加试卷 epId = new Utility().GetEPId(); ep = new ExaminationPaper { EP_Id = epId, ET_Id = ept.ET_Id, EPT_Id = ept.EPT_Id, EP_PaperStatus = (Byte)PaperStatus.Doing, EP_EndTime = ept.EPT_EndTime, EP_TimeSpan = ept.EPT_TimeSpan, EP_UserId = 1, EP_UserName = "", EP_Score = -1, EP_Remark = "", EP_AddTime = now, EP_Status = (Byte)Status.Available }; olsEni.Entry(ep).State = EntityState.Added; olsEni.SaveChanges(); // 添加答题数据 epqId = new Utility().GetEPQId(); eptqs = olsEni.ExaminationPaperTemplateQuestions.Where(m => m.EPT_Id == ept.EPT_Id).ToList(); foreach (var eptq in eptqs) { epq = new ExaminationPaperQuestion { EPQ_Id = epqId, EPQ_Answer = eptq.EPTQ_ModelAnswer, EPQ_Exactness = (Byte)AnswerStatus.Unset, EPQ_Critique = null, EPQ_AddTime = now, EP_Id = epId, EPTQ_Id = eptq.EPTQ_Id }; olsEni.Entry(epq).State = EntityState.Added; epqId += 1; } olsEni.SaveChanges(); #endregion expected = ResponseStatus.Success; actual = target.Change(); Assert.AreEqual(expected, ((ResponseJson)actual).status); olsEni.Entry(ep).State = EntityState.Detached; ep = null; ep = olsEni.ExaminationPapers.Single(m => m.EP_Id == epId); expected = (Byte)PaperStatus.Done; actual = ep.EP_PaperStatus; Assert.AreEqual(expected, actual); expected = 100; actual = ep.EP_Score; Assert.AreEqual(expected, actual); }