当前位置: 首页>>代码示例>>C#>>正文


C# AtomicComposition.Dispose方法代码示例

本文整理汇总了C#中AtomicComposition.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# AtomicComposition.Dispose方法的具体用法?C# AtomicComposition.Dispose怎么用?C# AtomicComposition.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AtomicComposition的用法示例。


在下文中一共展示了AtomicComposition.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Dispose_AllMethodsShouldThrow

        public void Dispose_AllMethodsShouldThrow()
        {
            var ct = new AtomicComposition();

            ct.Dispose();

            ExceptionAssert.ThrowsDisposed(ct, () => ct.AddCompleteAction(() => ct = null));
            ExceptionAssert.ThrowsDisposed(ct, () => ct.Complete());
            ExceptionAssert.ThrowsDisposed(ct, () => ct.SetValue(ct, 10));
            object value;
            ExceptionAssert.ThrowsDisposed(ct, () => ct.TryGetValue(ct, out value));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CompositionTransactionTests.cs

示例2: AddRevertAction_ShouldExecuteInReverseOrder

        public void AddRevertAction_ShouldExecuteInReverseOrder()
        {
            var ct = new AtomicComposition();
            Stack<int> stack = new Stack<int>();
            stack.Push(1);
            stack.Push(2);
            stack.Push(3);

            ct.AddRevertAction(() => Assert.AreEqual(1, stack.Pop()));
            ct.AddRevertAction(() => Assert.AreEqual(2, stack.Pop()));
            ct.AddRevertAction(() => Assert.AreEqual(3, stack.Pop()));

            ct.Dispose();

            Assert.IsTrue(stack.Count == 0);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:CompositionTransactionTests.cs

示例3: AddRevertAction_ShouldNotExecuteWhenCompleteted

        public void AddRevertAction_ShouldNotExecuteWhenCompleteted()
        {
            var ct = new AtomicComposition();
            bool executed = false;

            ct.AddRevertAction(() => executed = true);

            ct.Complete();

            Assert.IsFalse(executed);

            ct.Dispose();

            Assert.IsFalse(executed);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:CompositionTransactionTests.cs

示例4: SetValue_ChangeOuterValuesWhileHaveInner_ShouldThrow

        public void SetValue_ChangeOuterValuesWhileHaveInner_ShouldThrow()
        {
            var ct = new AtomicComposition();

            var ct2 = new AtomicComposition(ct);

            var key = new object();
            ExceptionAssert.Throws<InvalidOperationException>(() => ct.SetValue(key, 1));

            object value;
            Assert.IsFalse(ct2.TryGetValue(key, out value));
            Assert.IsFalse(ct.TryGetValue(key, out value));

            // remove the inner atomicComposition so the outer one becomes unlocked.
            ct2.Dispose();

            ct.SetValue(key, 2);
            Assert.IsTrue(ct.TryGetValue(key, out value));
            Assert.AreEqual(2, value);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:CompositionTransactionTests.cs


注:本文中的AtomicComposition.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。