Exemple #1
0
        public void TestDispose()
        {
            var result = new DatabaseResult <TestEntity>(DummyEnumerator(), 5);

            result.Dispose();
            try
            {
                var a = result.Current;
                Assert.Fail("This should've failed!");
            }
            catch (ObjectDisposedException) { }

            try
            {
                result.MoveNext();
                Assert.Fail("This should've failed!");
            }
            catch (ObjectDisposedException) { }

            try
            {
                var enumerator = result.GetEnumerator();
                enumerator.MoveNext();
                Assert.Fail("This should've failed!");
            }
            catch (ObjectDisposedException) { }
        }
Exemple #2
0
        public void TestEnumerator()
        {
            var result = new DatabaseResult <TestEntity>(DummyEnumerator(), 5);

            Assert.AreEqual(5, result.Count);

            for (int i = 0; i < 6; i++)
            {
                if (i == 5)
                {
                    Assert.IsFalse(result.MoveNext());
                }
                else
                {
                    Assert.IsTrue(result.MoveNext());

                    var entity = result.Current;
                    Assert.AreEqual(i, entity.Age);
                    Assert.AreEqual("FN" + i, entity.FirstName);
                    Assert.AreEqual("LN" + i, entity.LastName);
                }
            }
        }