Exemplo n.º 1
0
        public void StoppedRollbackTest()
        {
            var i          = new Shielded <int>();
            int retryCount = 0;

            Shield.InTransaction(() => {
                retryCount++;
                Shield.SideEffect(null, () => {
                    var localStore = i.GetType()
                                     .GetField("_locals", BindingFlags.Instance | BindingFlags.NonPublic)
                                     .GetValue(i);
                    Assert.IsNull(localStore.GetType()
                                  .GetField("_holderContext", BindingFlags.Instance | BindingFlags.NonPublic)
                                  .GetValue(localStore));
                });
                try
                {
                    i.Value = 10;
                    if (retryCount == 1)
                    {
                        Shield.Rollback();
                    }
                }
                catch (TransException) { }
            });
            Assert.AreEqual(2, retryCount);
        }