private static Validator CreateOperationDateValidator(BoundDate b) { var v = new Validator(); var i = new ItemValidator(); i.AddSecondaryConstraint(b); v.AddItemValidator(i, "operation_date", typeof(DateTime)); return(v); }
private static Validator CreateParentDobValidator(BoundDate b) { var v = new Validator(); var i = new ItemValidator(); i.AddSecondaryConstraint(b); v.AddItemValidator(i, "parent_dob", typeof(DateTime)); return(v); }
private static ValidationFailure CallValidate(string targetProperty, BoundDate b, Dictionary <string, object> d) { var keys = new string[d.Keys.Count]; var vals = new object[d.Values.Count]; d.Keys.CopyTo(keys, 0); d.Values.CopyTo(vals, 0); object o; d.TryGetValue(targetProperty, out o); return(b.Validate(o, vals, keys)); }
public void RenameColumn_ThreeColumns_HasCorrectName() { Validator v = new Validator(); v.AddItemValidator(new ItemValidator(), "OldCol2", typeof(string)); //this constraint ensures that OldCol2 is between OldCol1 and OldcCol3 BoundDate boundDate = new BoundDate(); boundDate.LowerFieldName = "OldCol1"; boundDate.UpperFieldName = "OldCol3"; v.ItemValidators[0].SecondaryConstraints.Add(boundDate); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("OldCol2", "NewCol2"); //before and after rename of col2 Assert.AreEqual(v.ItemValidators[0].TargetProperty, "OldCol2"); v.RenameColumns(dictionary); Assert.AreEqual(v.ItemValidators[0].TargetProperty, "NewCol2"); Assert.AreEqual(((BoundDate)v.ItemValidators[0].SecondaryConstraints[0]).LowerFieldName, "OldCol1"); Assert.AreEqual(((BoundDate)v.ItemValidators[0].SecondaryConstraints[0]).UpperFieldName, "OldCol3"); //now rename col 1 dictionary.Add("OldCol1", "NewCol1"); v.RenameColumns(dictionary); Assert.AreEqual(v.ItemValidators[0].TargetProperty, "NewCol2"); Assert.AreEqual(((BoundDate)v.ItemValidators[0].SecondaryConstraints[0]).LowerFieldName, "NewCol1"); Assert.AreEqual(((BoundDate)v.ItemValidators[0].SecondaryConstraints[0]).UpperFieldName, "OldCol3"); //finally rename col 3 dictionary.Add("OldCol3", "NewCol3"); v.RenameColumns(dictionary); //not strict because we will get not found otherwise since we already renamed the first one Assert.AreEqual(v.ItemValidators[0].TargetProperty, "NewCol2"); Assert.AreEqual(((BoundDate)v.ItemValidators[0].SecondaryConstraints[0]).LowerFieldName, "NewCol1"); Assert.AreEqual(((BoundDate)v.ItemValidators[0].SecondaryConstraints[0]).UpperFieldName, "NewCol3"); }
private ValidationFailure CallValidateOnValidData(string targetProperty, BoundDate b) { Dictionary <string, object> d = TestConstants.AdmissionDateOccursAfterDob; return(CallValidate(targetProperty, b, d)); }