Esempio n. 1
0
        public void Send()
        {
            // Arrange
            Mock <SynchronizationContext> mockSyncContext = new Mock <SynchronizationContext>();

            mockSyncContext
            .Expect(c => c.Send(It.IsAny <SendOrPostCallback>(), null))
            .Callback(
                delegate(SendOrPostCallback d, object state) {
                d(state);
            });

            AsyncManager helper    = new AsyncManager(mockSyncContext.Object);
            bool         wasCalled = false;

            // Act
            helper.Send(() => { wasCalled = true; });

            // Assert
            Assert.IsTrue(wasCalled);
        }