public void Test_DocArray_3() { using (var app = new AzosApplication(null, BASE_CONF)) { var doc = new DocArray(); doc.IMin = 5000; doc.DArray = new[] { new DocCompositeField { D1 = new DocDirectField { S1 = "zzzzkey" }, D2 = new DocDirectField { S1 = "key" } } }; var ve = doc.Validate(app); Aver.IsNotNull(ve); if (ve is FieldValidationException fve) { Console.WriteLine(fve.Message); Aver.IsTrue(fve.Message.Contains("list")); } else { Aver.Fail("Not a FVExcp"); } doc.DArray[0].D1.S1 = "key"; ve = doc.Validate(app); Aver.IsNull(ve); } }
public void Test_DocArray_2() { using (var app = new AzosApplication(null, BASE_CONF)) { var doc = new DocArray(); doc.IMin = 5;//below acceptable doc.DArray = new[] { new DocCompositeField { D1 = new DocDirectField { S1 = "key" }, D2 = new DocDirectField { S1 = "key" } } }; var ve = doc.Validate(app); Aver.IsNotNull(ve); if (ve is FieldValidationException fve) { fve.Message.See(); Aver.IsTrue(fve.Message.Contains("min")); } else { Aver.Fail(Constants.ERR_NOT_FVEXCP); } doc.IMin = 5000; ve = doc.Validate(app); Aver.IsNull(ve); } }
void Check(DocArray s, DocArray c) { if (s.items.Count != c.items.Count) { throw new Exception("Different number of rows"); } for (var i = 0; i < s.items.Count; i++) { Check(s[i], c[i]); } }
public void Test_DocArray_4() { using (var app = new AzosApplication(null, BASE_CONF)) { var doc = new DocArray(); doc.IMin = 1000; doc.DArray = new[] { null, null, null, new DocCompositeField { D1 = new DocDirectField { S1 = "key" }, D2 = new DocDirectField { S1 = "key" } } }; Aver.IsNull(doc.Validate(app)); } }
static void Show(StrongConnect c, DocArray da) { List <Column> cols = new List <Column>(); // of Column SDict <string, int> names = SDict <string, int> .Empty; SDict <int, SDict <string, string> > rows = SDict <int, SDict <string, string> > .Empty; // of string[] for (var b = c.description.First(); b != null; b = b.Next()) { names = names + (b.Value.Item2, b.Value.Item1); cols.Add(new Column(b.Value.Item2, b.Value.Item2.Length)); } for (int i = 0; i < da.items.Count; i++) { var dc = da[i]; var row = SDict <string, string> .Empty; for (var j = 0; j < dc.fields.Count; j++) { var f = dc.fields[j]; if (f.Key.StartsWith("_")) { continue; } if (!names.Contains(f.Key)) { throw new Exception("Unexpected column " + f.Key); } var k = names.Lookup(f.Key); var s = f.Value.ToString(); if (s.Length > cols[k].width) { cols[k].width = s.Length; } row = row + (f.Key, s); } rows = rows + (rows.Length.Value, row); } DrawLine(cols); ShowHeads(cols); DrawLine(cols); for (var j = 0; j < rows.Length.Value; j++) { ShowRow(rows.Lookup(j), cols); } DrawLine(cols); }