public void IndependantSnapshot()
        {
            try
            {
                Administrator.SetSnapshotIsolation(true);
                using (new CommandTimeoutScope(3))
                {
                    SetName("Mickey");

                    Assert.AreEqual("Mickey", GetName());

                    using (Transaction tr = new Transaction(true, IsolationLevel.Snapshot))
                    {
                        SetName("Minie");

                        Assert.AreEqual("Minie", GetName());

                        using (Transaction tr2 = new Transaction(true, IsolationLevel.Snapshot))
                        {
                            Assert.AreEqual("Mickey", GetName());                      //Independant transaction

                            Assert2.Throws <TimeoutException>(() => SetName("Mouse")); //Timeout writing

                            return;
                        }
                    }
                }
            }
            finally
            {
                Administrator.SetSnapshotIsolation(false);
            }
        }
        public void IndependantBlocking()
        {
            Administrator.SetSnapshotIsolation(false);

            using (new CommandTimeoutScope(3))
            {
                SetName("Mickey");

                Assert.AreEqual("Mickey", GetName());

                using (Transaction tr = new Transaction())
                {
                    SetName("Minie");

                    Assert.AreEqual("Minie", GetName());

                    using (Transaction tr2 = new Transaction(true))
                    {
                        Assert2.Throws <TimeoutException>(() => GetName()); //Timeout reading

                        return;
                    }
                }
            }
        }
        public void RollbackNested()
        {
            SetName("Mickey");

            Assert.AreEqual("Mickey", GetName());

            using (Transaction tr = new Transaction())
            {
                SetName("Minie");

                Assert.AreEqual("Minie", GetName());

                using (Transaction tr2 = new Transaction())
                {
                    SetName("Mouse");

                    Assert.AreEqual("Mouse", GetName());
                    //tr.Commit();
                }
                Assert2.Throws <InvalidOperationException>(() => tr.Commit());
            }

            Assert.AreEqual("Mickey", GetName());

            Starter.Dirty();
        }
示例#4
0
        public void CompareExpression()
        {
            Expression <Func <int, int> > f1 = a => a;
            Expression <Func <int, int> > f2 = a => a;
            Expression <Func <int, int> > f3 = b => b;

            Assert.IsTrue(ExpressionComparer.AreEqual(f1, f2, checkParameterNames: true));
            Assert.IsTrue(ExpressionComparer.AreEqual(f1, f2, checkParameterNames: false));
            Assert.IsFalse(ExpressionComparer.AreEqual(f1, f3, checkParameterNames: true));
            Assert.IsTrue(ExpressionComparer.AreEqual(f1, f3, checkParameterNames: false));

            f1.Evaluate(1);
            Assert2.Throws <InvalidOperationException>("cache", () => f2.Evaluate(2));
        }
示例#5
0
        public void RetrieveSealed()
        {
            using (Transaction tr = new Transaction())
                using (new EntityCache(EntityCacheType.ForceNewSealed))
                {
                    var albums = Database.Query <AlbumEntity>().ToList();

                    Assert2.AssertAll(GraphExplorer.FromRoots(albums), a => a.Modified == ModifiedState.Sealed);

                    Assert2.Throws <InvalidOperationException>("sealed", () => albums.First().Name = "New name");


                    var notes = Database.Query <NoteWithDateEntity>().ToList();
                    Assert2.AssertAll(GraphExplorer.FromRoots(notes), a => a.Modified == ModifiedState.Sealed);

                    //tr.Commit();
                }
        }
        public void NestedNamedRollback()
        {
            using (Transaction tr = new Transaction())
            {
                SetName("Mickey");

                Assert.AreEqual("Mickey", GetName());

                using (Transaction tr2 = new Transaction("hola"))
                {
                    SetName("Minie");

                    Assert.AreEqual("Minie", GetName());

                    using (Transaction tr3 = new Transaction())
                    {
                        SetName("Mouse");

                        Assert.AreEqual("Mouse", GetName());

                        //tr3.Commit();
                    }

                    Assert2.Throws <InvalidOperationException>(() =>
                    {
                        using (Transaction tr3 = new Transaction())
                        {
                            SetName("Mouse");

                            Assert.AreEqual("Mouse", GetName());

                            tr3.Commit();
                        }

                        tr2.Commit();
                    });
                }

                tr.Commit();
            }

            Assert.AreEqual("Mickey", GetName());
        }