public void AddNewCriteriaEntries_Versioning() { Template template; TemplateViewModel templateViewModel; CreateTemplateAndField(new FormViewModel(), Constants.TemplateFieldType.TEXTBOX, "this is for testing", out template, out templateViewModel); templateViewModel = _formManager.FindTemplateToEdit(template.TemplateID); Assert.IsNotNull(templateViewModel.Fields); Assert.AreEqual(1, templateViewModel.Fields.Count); templateViewModel.Entries = _formManager.HasSubmissions(templateViewModel).ToList(); Assert.AreEqual(0, templateViewModel.Entries.Count); fillin("1", templateViewModel, "SubmitFields[1].TextBox", "ABC HelloTest"); UpdateByAddingTemplateField(template, 2, Constants.TemplateFieldType.TEXTBOX, "this is for another testing", out templateViewModel); CriteriaFieldViewModel result = _target.AddNewCriteriaEntries(1); Assert.IsNotNull(result); Assert.AreEqual(4, result.FieldLabels.Count); Assert.AreEqual("this is for testing", result.FieldLabels[0].Text); Assert.AreEqual("1: this is for testing", result.FieldLabels[1].Text); Assert.AreEqual("this is for another testing", result.FieldLabels[2].Text); }
public void GenerateFlitering_OneRecordWithSubRecordUsingSimpleMapping() { FormController target = new FormController(); PrivateObject obj = new PrivateObject(target); List <CriteriaFieldViewModel> fields = new List <CriteriaFieldViewModel>(); CriteriaFieldViewModel record = new CriteriaFieldViewModel(); record.CriteriaValue = new Dictionary <string, string>(); record.CriteriaSubFields = new List <CriteriaSubFieldViewModel>(); record.TemplateFieldID = "TWO COL"; record.CriteriaLogic = "neq"; record.CriteriaValue[record.TemplateFieldID] = "FIRSTCOL"; CriteriaSubFieldViewModel subRecord = new CriteriaSubFieldViewModel(); subRecord.CriteriaValue = new Dictionary <string, string>(); subRecord.OperatorLogic = "and"; subRecord.CriteriaLogic = "gt"; subRecord.CriteriaValue[record.TemplateFieldID] = "SECCOL"; record.CriteriaSubFields.Add(subRecord); fields.Add(record); var retVal = obj.Invoke("GenerateFlitering", new object[] { fields }); Assert.AreEqual("[TWO COL] <> 'FIRSTCOL' and [TWO COL] > 'SECCOL'", retVal); }
public void CreateFormEntriesDataTableTest_FilteringWithQuoteValue() { Template template; TemplateViewModel templateViewModel; CreateTemplateAndField(new FormViewModel(), Constants.TemplateFieldType.TEXTBOX, "this is for testing", out template, out templateViewModel); templateViewModel = _formManager.FindTemplateToEdit(template.TemplateID); Assert.IsNotNull(templateViewModel.Fields); Assert.AreEqual(1, templateViewModel.Fields.Count); templateViewModel.Entries = _formManager.HasSubmissions(templateViewModel).ToList(); Assert.AreEqual(0, templateViewModel.Entries.Count); fillin("1", templateViewModel, "SubmitFields[1].TextBox", "ABC's HelloTest"); fillin("1", templateViewModel, "SubmitFields[1].TextBox", "ZXY's HelloTest"); fillin("1", templateViewModel, "SubmitFields[1].TextBox", "HHH's HelloTest"); Dictionary <string, string> criteriaValue = new Dictionary <string, string>(); criteriaValue.Add("1", "ABC's"); CriteriaFieldViewModel criteriaFieldViewModel = new CriteriaFieldViewModel() { TemplateFieldID = "1", CriteriaLogic = "contains", CriteriaValue = criteriaValue }; var criteriaFields = new List <CriteriaFieldViewModel>(); criteriaFields.Add(criteriaFieldViewModel); FormExportViewModel model = new FormExportViewModel() { FormID = 1, CriteriaFields = criteriaFields }; DataTable result = _target.CreateFormEntriesDataTable(model).ValuesDataTable; Assert.IsNotNull(result); Assert.AreEqual(3, result.Columns.Count); Assert.AreEqual("Nric", result.Columns[0].ColumnName); DataColumn column = result.Columns[1]; Assert.AreEqual("this is for testing", column.ColumnName); Assert.AreEqual(1, result.Rows.Count); DataRow row = result.Rows[0]; Assert.AreEqual("", row["Nric"]); Assert.AreEqual("ABC's HelloTest", row["this is for testing"]); }
public void GenerateFlitering_OneRecordUsingSimpleMapping() { FormController target = new FormController(); PrivateObject obj = new PrivateObject(target); List <CriteriaFieldViewModel> fields = new List <CriteriaFieldViewModel>(); CriteriaFieldViewModel record = new CriteriaFieldViewModel(); record.CriteriaValue = new Dictionary <string, string>(); record.TemplateFieldID = "TWO COL"; record.CriteriaLogic = "eq"; record.CriteriaValue[record.TemplateFieldID] = "TEST"; fields.Add(record); var retVal = obj.Invoke("GenerateFlitering", new object[] { fields }); Assert.AreEqual("[TWO COL] = 'TEST'", retVal); }
public void GenerateFlitering_MultipleRecordUsingSimpleMapping() { FormController target = new FormController(); PrivateObject obj = new PrivateObject(target); List <CriteriaFieldViewModel> fields = new List <CriteriaFieldViewModel>(); CriteriaFieldViewModel recordOne = new CriteriaFieldViewModel(); recordOne.CriteriaValue = new Dictionary <string, string>(); recordOne.TemplateFieldID = "FIRST COL"; recordOne.CriteriaLogic = "gte"; recordOne.CriteriaValue[recordOne.TemplateFieldID] = "FIRSTVAL"; fields.Add(recordOne); CriteriaFieldViewModel recordTwo = new CriteriaFieldViewModel(); recordTwo.CriteriaValue = new Dictionary <string, string>(); recordTwo.TemplateFieldID = "SEC COL"; recordTwo.CriteriaLogic = "lt"; recordTwo.CriteriaValue[recordTwo.TemplateFieldID] = "SECVAL"; fields.Add(recordTwo); CriteriaFieldViewModel recordThree = new CriteriaFieldViewModel(); recordThree.CriteriaValue = new Dictionary <string, string>(); recordThree.TemplateFieldID = "THIRD COL"; recordThree.CriteriaLogic = "lte"; recordThree.CriteriaValue[recordThree.TemplateFieldID] = "THIRDVAL"; fields.Add(recordThree); var retVal = obj.Invoke("GenerateFlitering", new object[] { fields }); Assert.AreEqual("[FIRST COL] >= 'FIRSTVAL' OR [SEC COL] < 'SECVAL' OR [THIRD COL] <= 'THIRDVAL'", retVal); }