Exemple #1
0
        public void Create()
        {
            var books  = CreatBooksData();
            var reader = new PocoReader <BookClass>(books);

            DisplayReader(reader);
        }
Exemple #2
0
        public void Basics()
        {
            var objects = Enumerable.Range(0, 10).Select(i => new TestPoco { Foo = "#" + i, Bar = i }).ToList();
            var reader = new PocoReader(objects);
            for (var i = 0; i < objects.Count; i++)
            {
                Assert.IsTrue(reader.Read());
                Assert.AreEqual("#" + i, reader["foo"]);
                Assert.AreEqual(i, reader["bar"]);
            }

            Assert.IsFalse(reader.Read());
            Assert.AreEqual(objects.Count - 1, reader["bar"]);
        }
Exemple #3
0
        public async Task PocoTest_Reader()
        {
            var items = new List <SamplePocoClass>
            {
                new SamplePocoClass("column1", 1, new DateTime(2000, 01, 02)),
                new SamplePocoClass("column2", 2, new DateTime(2000, 01, 03)),
                new SamplePocoClass("column3", 3, new DateTime(2000, 01, 04)),
            };

            var pocoReader = new PocoReader <SamplePocoClass>(items);

            var count = 0;

            while (await pocoReader.ReadAsync())
            {
                count++;
                Assert.Equal("column" + count, pocoReader["StringColumn"]);
                Assert.Equal(count, pocoReader["IntColumn"]);
                Assert.Equal(new DateTime(2000, 01, 01).AddDays(count), pocoReader["DateColumn"]);
            }

            Assert.Equal(3, count);
        }