public void BoundFakesyncedFunc_Invoked_ReturnsValue()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(false);
         var action     = context.Bind(() => { return(13); }, syncObject);
         int result     = action();
         Assert.AreEqual(13, result, "Bound func did not return result");
     }
 }
 public void BoundObjectsyncedFunc_Invoked_UsesSyncObject()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action     = context.Bind(() => { return(13); }, syncObject);
         int result     = action();
         Assert.IsTrue(syncObject.sawInvoke, "Bound action did not run through synchronizing object");
     }
 }
 public void BoundFakesyncedFunc_Invoked_DoesNotUseSyncObject()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(false);
         var action     = context.Bind(() => { return(13); }, syncObject);
         int result     = action();
         Assert.IsFalse(syncObject.sawInvoke, "Bound action did run through synchronizing object");
     }
 }
 public void InvalidBoundObjectsyncedFunc_Invoked_ReturnsDefault()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action     = context.Bind(() => { return(13); }, syncObject);
         context.Reset();
         int result = action();
         Assert.AreEqual(0, result, "Invalid func returned non-default value");
     }
 }
        public void BoundFakesyncedFunc_Invoked_Executes()
        {
            bool sawAction = false;

            using (CallbackContext context = new CallbackContext())
            {
                var syncObject = new FakeFuncSynchronizingObject(false);
                var action     = context.Bind(() => { sawAction = true; return(13); }, syncObject);
                int result     = action();
                Assert.IsTrue(sawAction, "Bound action did not run");
            }
        }
        public void BoundObjectsyncedFunc_Invoked_SynchronizesWithSyncObject()
        {
            int sawActionThread = Thread.CurrentThread.ManagedThreadId;

            using (CallbackContext context = new CallbackContext())
            {
                var syncObject = new FakeFuncSynchronizingObject(true);
                var action     = context.Bind(() => { sawActionThread = Thread.CurrentThread.ManagedThreadId; return(13); }, syncObject);
                int result     = action();
                Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, sawActionThread, "Bound action was not synchronized");
            }
        }
 public void InvalidBoundObjectsyncedFunc_Invoked_SynchronizesWithSyncObject()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action = context.Bind(() => { return 13; }, syncObject);
         context.Reset();
         int result = action();
         Assert.IsTrue(syncObject.sawInvoke, "Bound action did not run through synchronizing object");
     }
 }
 public void InvalidBoundObjectsyncedFunc_Invoked_ReturnsDefault()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action = context.Bind(() => { return 13; }, syncObject);
         context.Reset();
         int result = action();
         Assert.AreEqual(0, result, "Invalid func returned non-default value");
     }
 }
        public void InvalidBoundObjectsyncedFunc_Invoked_DoesNotExecute()
        {
            int sawActionThread = Thread.CurrentThread.ManagedThreadId;

            using (CallbackContext context = new CallbackContext())
            {
                var syncObject = new FakeFuncSynchronizingObject(true);
                var action = context.Bind(() => { sawActionThread = Thread.CurrentThread.ManagedThreadId; return 13; }, syncObject);
                context.Reset();
                int result = action();
                Assert.AreEqual(Thread.CurrentThread.ManagedThreadId, sawActionThread, "Bound action was executed");
            }
        }
 public void BoundObjectsyncedFunc_Invoked_ReturnsValue()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action = context.Bind(() => { return 13; }, syncObject);
         int result = action();
         Assert.AreEqual(13, result, "Bound func did not return result");
     }
 }
        public void BoundObjectsyncedFunc_Invoked_Executes()
        {
            bool sawAction = false;

            using (CallbackContext context = new CallbackContext())
            {
                var syncObject = new FakeFuncSynchronizingObject(true);
                var action = context.Bind(() => { sawAction = true; return 13; }, syncObject);
                int result = action();
                Assert.IsTrue(sawAction, "Bound action did not run");
            }
        }
 public void BoundFakesyncedFunc_Invoked_DoesNotUseSyncObject()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(false);
         var action = context.Bind(() => { return 13; }, syncObject);
         int result = action();
         Assert.IsFalse(syncObject.sawInvoke, "Bound action did run through synchronizing object");
     }
 }
        public void BoundFakesyncedFunc_Invoked_DoesNotSynchronizeWithSyncObject()
        {
            int sawActionThread = Thread.CurrentThread.ManagedThreadId;

            using (CallbackContext context = new CallbackContext())
            {
                var syncObject = new FakeFuncSynchronizingObject(false);
                var action = context.Bind(() => { sawActionThread = Thread.CurrentThread.ManagedThreadId; return 13; }, syncObject);
                int result = action();
                Assert.AreEqual(Thread.CurrentThread.ManagedThreadId, sawActionThread, "Bound action was not run inline");
            }
        }