public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
        {
            DynamicMock        mockSynchronizeInvoke = new DynamicMock(typeof(ISynchronizeInvoke));
            StubProjectMonitor containedMonitor      = new StubProjectMonitor("test");

            SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
                containedMonitor,
                (ISynchronizeInvoke)mockSynchronizeInvoke.MockInstance);

            MonitorBuildOccurredEventHandler delegateToBuildOccurred = new MonitorBuildOccurredEventHandler(Monitor_BuildOccurred);

            monitor.BuildOccurred += delegateToBuildOccurred;

            mockSynchronizeInvoke.Expect("BeginInvoke", delegateToBuildOccurred, new IsTypeOf(typeof(object[])));
            containedMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(null, BuildTransition.StillFailing));

            mockSynchronizeInvoke.Verify();
        }
        public void WhenPolledIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
        {
            DynamicMock        mockSynchronizeInvoke = new DynamicMock(typeof(ISynchronizeInvoke));
            StubProjectMonitor containedMonitor      = new StubProjectMonitor("test");

            SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
                containedMonitor,
                (ISynchronizeInvoke)mockSynchronizeInvoke.MockInstance);

            MonitorPolledEventHandler delegateToPolledMethod = new MonitorPolledEventHandler(Monitor_Polled);

            monitor.Polled += delegateToPolledMethod;

            mockSynchronizeInvoke.Expect("BeginInvoke", delegateToPolledMethod, new IsTypeOf(typeof(object[])));
            containedMonitor.OnPolled(new MonitorPolledEventArgs(containedMonitor));

            mockSynchronizeInvoke.Verify();
        }
        public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
        {
            var mockSynchronizeInvoke           = new Mock <ISynchronizeInvoke>();
            StubProjectMonitor containedMonitor = new StubProjectMonitor("test");

            SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
                containedMonitor,
                (ISynchronizeInvoke)mockSynchronizeInvoke.Object);

            MonitorBuildOccurredEventHandler delegateToBuildOccurred = new MonitorBuildOccurredEventHandler(Monitor_BuildOccurred);

            monitor.BuildOccurred += delegateToBuildOccurred;

            mockSynchronizeInvoke.Setup(invoke => invoke.BeginInvoke(delegateToBuildOccurred, It.IsAny <object[]>())).Verifiable();
            containedMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(null, BuildTransition.StillFailing));

            mockSynchronizeInvoke.Verify();
        }
        public void WhenPolledIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
        {
            var mockSynchronizeInvoke           = new Mock <ISynchronizeInvoke>();
            StubProjectMonitor containedMonitor = new StubProjectMonitor("test");

            SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
                containedMonitor,
                (ISynchronizeInvoke)mockSynchronizeInvoke.Object);

            MonitorPolledEventHandler delegateToPolledMethod = new MonitorPolledEventHandler(Monitor_Polled);

            monitor.Polled += delegateToPolledMethod;

            mockSynchronizeInvoke.Setup(invoke => invoke.BeginInvoke(delegateToPolledMethod, It.IsAny <object[]>())).Verifiable();
            containedMonitor.OnPolled(new MonitorPolledEventArgs(containedMonitor));

            mockSynchronizeInvoke.Verify();
        }
        public void MethodsAndPropertiesDoSimpleDelagationOntoInjectedMonitor()
        {
            DynamicMock mockProjectMonitor = new DynamicMock(typeof(IProjectMonitor));

            SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
                (IProjectMonitor)mockProjectMonitor.MockInstance, null);

            mockProjectMonitor.ExpectAndReturn("ProjectState", null);
            Assert.IsNull(monitor.ProjectState);

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            mockProjectMonitor.Expect("ForceBuild", parameters, (string)null);
            monitor.ForceBuild(parameters, null);

            mockProjectMonitor.Expect("Poll");
            monitor.Poll();

            mockProjectMonitor.Verify();
        }
        public void MethodsAndPropertiesDoSimpleDelagationOntoInjectedMonitor()
        {
            var mockProjectMonitor = new Mock <IProjectMonitor>();

            SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
                (IProjectMonitor)mockProjectMonitor.Object, null);

            mockProjectMonitor.SetupGet(_monitor => _monitor.ProjectState).Returns(() => null).Verifiable();
            Assert.IsNull(monitor.ProjectState);

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            mockProjectMonitor.Setup(_monitor => _monitor.ForceBuild(parameters, null)).Verifiable();
            monitor.ForceBuild(parameters, null);

            mockProjectMonitor.Setup(_monitor => _monitor.Poll()).Verifiable();
            monitor.Poll();

            mockProjectMonitor.Verify();
        }