コード例 #1
0
        public void Test_storage_and_query()
        {
            var item = new ClassWithEvents {
                One = 1
            };

            item.MyDelegateMember = item.Invoke;
            item.MyCustomEvent   += item.EventRised;

            OdbFactory.Delete(DbName);

            using (var odb = OdbFactory.Open(DbName))
            {
                odb.Store(item);
            }

            ClassWithEvents storedItem;

            using (var odb = OdbFactory.Open(DbName))
            {
                storedItem = odb.QueryAndExecute <ClassWithEvents>().GetFirst();
            }

            Assert.That(storedItem, Is.Not.Null);
            Assert.That(storedItem.One, Is.EqualTo(1));
//            storedItem.MyDelegateMember(); //-> will throw System.AccessViolationException
            Assert.That(item.WasInvoked, Is.False);
//            storedItem.OnMyCustomEvent(); // -> will throw System.AccessViolationException
            Assert.That(item.EventWasRised, Is.False);
        }
コード例 #2
0
        public void Test_storage_and_query()
        {
            var item = new ClassWithEvents {One = 1};
            item.MyDelegateMember = item.Invoke;
            item.MyCustomEvent += item.EventRised;

            OdbFactory.Delete(DbName);

            using (var odb = OdbFactory.Open(DbName))
            {
                odb.Store(item);
            }

            ClassWithEvents storedItem;
            using (var odb = OdbFactory.Open(DbName))
            {
                storedItem = odb.QueryAndExecute<ClassWithEvents>().GetFirst();
            }

            Assert.That(storedItem, Is.Not.Null);
            Assert.That(storedItem.One, Is.EqualTo(1));
            //            storedItem.MyDelegateMember(); //-> will throw System.AccessViolationException
            Assert.That(item.WasInvoked, Is.False);
            //            storedItem.OnMyCustomEvent(); // -> will throw System.AccessViolationException
            Assert.That(item.EventWasRised, Is.False);
        }