Beispiel #1
0
        public void Rec()
        {
            var db   = CopyDb("");
            var file = File("");
            var rec  = new DaoRec(db, "Tabl");

            Assert.IsNotNull(rec.DaoDb);
            Assert.AreEqual(file, rec.DaoDb.File);
            Assert.AreEqual(7, rec.FieldsCount);
            Assert.IsTrue(rec.ContainsField("IntField"));
            Assert.IsTrue(rec.ContainsField("RealField"));
            Assert.IsTrue(rec.ContainsField("StringField1"));
            Assert.IsTrue(rec.ContainsField("id"));

            Assert.AreEqual(5, rec.RecordCount);
            Assert.IsTrue(rec.HasRows);
            Assert.IsFalse(rec.EOF);
            Assert.IsFalse(rec.BOF);
            Assert.IsFalse(rec.Read());
            Assert.IsTrue(rec.MoveFirst());
            Assert.IsTrue(rec.MoveNext());
            Assert.IsTrue(rec.MoveFirst());
            Assert.IsFalse(rec.MovePrevious());
            Assert.IsTrue(rec.BOF);
            Assert.IsFalse(rec.EOF);
            Assert.IsTrue(rec.MoveLast());
            Assert.IsTrue(rec.MovePrevious());
            Assert.IsTrue(rec.MoveLast());
            Assert.IsFalse(rec.MoveNext());
            Assert.IsTrue(rec.EOF);
            Assert.IsFalse(rec.BOF);
            Assert.IsFalse(rec.NoMatch);
            rec.Dispose();

            rec = new DaoRec(db, "EmptyTabl");
            Assert.IsNotNull(rec.DaoDb);
            Assert.AreEqual(file, rec.DaoDb.File);
            Assert.AreEqual(1, rec.FieldsCount);
            Assert.IsTrue(rec.ContainsField("StringField"));

            Assert.AreEqual(0, rec.RecordCount);
            Assert.IsFalse(rec.HasRows);
            Assert.IsTrue(rec.EOF);
            Assert.IsTrue(rec.BOF);
            Assert.IsFalse(rec.Read());
            Assert.IsFalse(rec.MoveFirst());
            Assert.IsFalse(rec.MoveNext());
            Assert.IsFalse(rec.MoveLast());
            Assert.IsFalse(rec.MovePrevious());
            Assert.IsTrue(rec.EOF);
            Assert.IsTrue(rec.EOF);
            Assert.IsFalse(rec.NoMatch);
            rec.Dispose();

            rec = new DaoRec(db, "SELECT Tabl.IntField, Tabl.RealField, SubTabl.StringSubField FROM Tabl INNER JOIN SubTabl ON Tabl.Id = SubTabl.ParentId");
            Assert.IsNotNull(rec.DaoDb);
            Assert.AreEqual(file, rec.DaoDb.File);
            Assert.AreEqual(3, rec.FieldsCount);
            Assert.IsTrue(rec.ContainsField("IntField"));
            Assert.IsTrue(rec.ContainsField("RealField"));
            Assert.IsTrue(rec.ContainsField("StringSubField"));

            Assert.AreEqual(7, rec.RecordCount);
            Assert.IsTrue(rec.HasRows);
            Assert.IsFalse(rec.EOF);
            Assert.IsFalse(rec.BOF);
            Assert.IsFalse(rec.Read());
            Assert.IsTrue(rec.MoveFirst());
            Assert.IsTrue(rec.MoveNext());
            Assert.IsTrue(rec.MoveFirst());
            Assert.IsFalse(rec.MovePrevious());
            Assert.IsTrue(rec.BOF);
            Assert.IsFalse(rec.EOF);
            Assert.IsTrue(rec.MoveLast());
            Assert.IsTrue(rec.MovePrevious());
            Assert.IsTrue(rec.MoveLast());
            Assert.IsFalse(rec.MoveNext());
            Assert.IsTrue(rec.EOF);
            Assert.IsFalse(rec.BOF);
            Assert.IsFalse(rec.NoMatch);
            rec.Dispose();

            db.Dispose();
        }