public void AdquiresTheLockDuringTheExecutionAndReleaseItAtTheEnd()
 {
     var context = new SynchronizationContext();
     Assert.IsFalse(context.IsLockAcquired);
     context.Execute(() => Assert.IsTrue(context.IsLockAcquired));
     Assert.IsFalse(context.IsLockAcquired);
 }
Esempio 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);
            }
Esempio 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);
 }
Esempio 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);
            }