public void ValidateDataPass_DefaultValue( ) { var expDefault = true; // modify schema to have default Action <IField> defCfg = (f) => { f.Name = "Active"; f.Attributes = Attribs.Default; f.Data = new DataValue(f.Type, f.Attributes).Value(expDefault); }; schema.AddType(DataType.Boolean, defCfg); var validator = GetValidator(schema); var pkey = new DataValue(schema.Fields[0].Type, schema.Fields[1].Attributes); var defVal = new DataValue(schema.Fields[6].Type, schema.Fields[6].Attributes); var data = new object[] { pkey, "Peter", "Gilbert", "Fraub", new DateTime(1968, 12, 2), DateTime.Now, defVal }; Assert.IsTrue(validator.Validate(data)); }
public void InsertWithDefaultValue( ) { var expDefault = true; // modify schema to have default Action <IField> defCfg = (f) => { f.Name = "Active"; f.Attributes = Attribs.Default; f.Data = new DataValue(f.Type, f.Attributes).Value(expDefault); }; schema.AddType(DataType.Boolean, defCfg); var inserter = GetInserter(schema, cache); var pkey = new DataValue(schema.Fields[0].Type, schema.Fields[1].Attributes); var defVal = new DataValue(schema.Fields[6].Type, schema.Fields[6].Attributes); var data = new object[] { pkey, "Peter", "Gilbert", "Fraub", new DateTime(1968, 12, 2), DateTime.Now, defVal }; inserter.Insert(indexer, data); Assert.AreEqual(expDefault, (bool)data[6]); }