public void AdquiresTheLockDuringTheExecutionAndReleaseItAtTheEnd()
 {
     var context = new SynchronizationContext();
     Assert.IsFalse(context.IsLockAcquired);
     context.Execute(() => Assert.IsTrue(context.IsLockAcquired));
     Assert.IsFalse(context.IsLockAcquired);
 }
Exemplo n.º 2
0
            public void AdquiresTheLockDuringTheExecutionAndReleaseItAtTheEnd()
            {
                var context = new SynchronizationContext();

                Assert.IsFalse(context.IsLockAcquired);
                context.Execute(() => Assert.IsTrue(context.IsLockAcquired));
                Assert.IsFalse(context.IsLockAcquired);
            }
            public void NestedExecuteCallAreAllowed()
            {
                var context = new SynchronizationContext();
                Assert.IsFalse(context.IsLockAcquired);
                int expected = new Random().Next(50, 100);
                int result = context.Execute(() =>
                    {
                        int nestedResult = context.Execute(() =>
                            {
                                Assert.IsTrue(context.IsLockAcquired);
                                return expected;
                            });
                        Assert.IsTrue(context.IsLockAcquired);
                        return nestedResult;
                    });

                Assert.IsFalse(context.IsLockAcquired);
                Assert.AreEqual(expected, result);
            }
Exemplo n.º 4
0
            public void NestedExecuteCallAreAllowed()
            {
                var context = new SynchronizationContext();

                Assert.IsFalse(context.IsLockAcquired);
                int expected = new Random().Next(50, 100);
                int result   = context.Execute(() =>
                {
                    int nestedResult = context.Execute(() =>
                    {
                        Assert.IsTrue(context.IsLockAcquired);
                        return(expected);
                    });
                    Assert.IsTrue(context.IsLockAcquired);
                    return(nestedResult);
                });

                Assert.IsFalse(context.IsLockAcquired);
                Assert.AreEqual(expected, result);
            }
 public void AdquiresTheLockDuringTheExecutionAndReleaseItAtTheEndAndReturnAValue()
 {
     var context = new SynchronizationContext();
     Assert.IsFalse(context.IsLockAcquired);
     int expected = new Random().Next(50, 100);
     int result = context.Execute(() =>
         {
             Assert.IsTrue(context.IsLockAcquired);
             return expected;
         });
     Assert.IsFalse(context.IsLockAcquired);
     Assert.AreEqual(expected, result);
 }
Exemplo n.º 6
0
            public void AdquiresTheLockDuringTheExecutionAndReleaseItAtTheEndAndReturnAValue()
            {
                var context = new SynchronizationContext();

                Assert.IsFalse(context.IsLockAcquired);
                int expected = new Random().Next(50, 100);
                int result   = context.Execute(() =>
                {
                    Assert.IsTrue(context.IsLockAcquired);
                    return(expected);
                });

                Assert.IsFalse(context.IsLockAcquired);
                Assert.AreEqual(expected, result);
            }