Exemplo n.º 1
0
        public void Test03_Batch()
        {
            var doc = new Doc2 {
                Name = "Dogman", List = new List <Doc1> {
                    new Doc1 {
                        S1 = "1", S2 = "01", I1 = 15
                    },
                    new Doc1 {
                        S1 = "2", S2 = "sf01", I1 = 1555
                    },
                    new Doc1 {
                        S1 = "323456", S2 = "gdfg01", I1 = -1
                    }
                }
            };

            var got = doc.Validate(new ValidState(null, ValidErrorMode.Batch));

            got.See();

            Aver.IsTrue(got.IsAssigned);
            Aver.IsTrue(got.HasErrors);
            Aver.IsFalse(got.NoErrors);
            Aver.AreEqual(7, got.ErrorCount);
            Aver.IsTrue(got.ShouldContinue);
            Aver.IsFalse(got.ShouldStop);
            Aver.IsNotNull(got.Error);

            var batch = got.Error as ValidationBatchException;

            Aver.IsNotNull(batch);
            Aver.IsNotNull(batch.Batch);
            Aver.AreEqual(7, batch.Batch.Count);
        }