public void RemoveCurrentThrowsConnectionException()
        {
            mockME.ExpectAndThrow("RemoveCurrent", new ConnectionException(QueueReference.DEFAULT), null);
            SystemMessageEnumerator me = CreateEnumerator((IMessageEnumerator)mockME.MockInstance);

            me.RemoveCurrent();
        }
        [Test] // Bug fix
        public void NotInfiniteLoopRemovingAnApplicationWithAManagerThatThrowsExceptionWhenStopped()
        {
            factoryMock.ExpectAndReturn("CreateApplicationWatcherMonitor", watcher);
            watcherMock.Expect("StartWatching");
            watcherMock.ExpectAndThrow("StopWatching", new Exception());
            AddApplication();
            ForwardingDeployEventDispatcher dispatcher = new ForwardingDeployEventDispatcher();

            dispatcher.DeployEvent += new DeployEventHandler(dispatcher_DeployEvent);
            location = new FileSystemDeployLocation(dispatcher, factory, deployPath, true);
            Directory.Delete(sampleDir, true);
            forwardDispatcherSync.Acquire();
            Assert.IsTrue(deployEventDispatched, "removal not dispatched in case of error on application watcher");
        }
Exemple #3
0
        public void WhenPollingEncountersAnExceptionThePolledEventIsStillFired()
        {
            Assert.AreEqual(0, pollCount);

            mockProjectManager.ExpectAndThrow("ProjectName", new Exception("should be caught"));
            monitor.Poll();
            Assert.AreEqual(1, pollCount);
        }
Exemple #4
0
        public void WhenPollingEncountersAnExceptionThePolledEventIsStillFired()
        {
            Assert.AreEqual(0, pollCount);
            Exception ex = new Exception("should be caught");

            mockServerManager.ExpectAndThrow("GetCruiseServerSnapshot", ex);
            monitor.Poll();
            Assert.AreEqual(1, pollCount);
            Assert.AreEqual(ex, monitor.ConnectException);
        }
        public void ShouldReturnFalseDueToException()
        {
            docMock = new DynamicMock(typeof(HTMLDocument));
            DynamicMock window = new DynamicMock(typeof(IHTMLWindow2));

            docMock.ExpectAndReturn("get_parentWindow", window.MockInstance);
            window.ExpectAndThrow("execScript", new ArgumentException(), "someScript()", "JScript");

            Assert.AreEqual(false, Util.RunJavaScript((HTMLDocument)docMock.MockInstance, "someScript()"));
        }
        public void IfThereIsAnExceptionBuildMessageShouldPublishExceptionMessage()
        {
            DynamicMock mock = new DynamicMock(typeof(IMessageBuilder));

            mock.ExpectAndThrow("BuildMessage", new Exception("oops"), new IsAnything());
            publisher = new EmailPublisher((IMessageBuilder)mock.MockInstance);
            string message = publisher.CreateMessage(new IntegrationResult());

            AssertContains("oops", message);
        }
        public void ErrorsWhileGettingTheReferenceToTheServiceAreVisibleToTheUser()
        {
            DynamicMock mockFactory = new DynamicMock(typeof(ISpringServiceFactory));
            DynamicMock mockService = new DynamicMock(typeof(ISpringService));

            mockService.ExpectAndThrow("DeployInformations", new Exception("this and that"));
            mockFactory.ExpectAndReturn("SpringService", mockService.Object);

            monitor.ServiceFactory = mockFactory.Object as ISpringServiceFactory;
            Assert.AreEqual("service not available: this and that", serviceStatus.Text);
            Assert.AreEqual(String.Empty, appStatus.Text);
            ScreenShot("service not available.gif");
        }
        public void ShouldGiveViewOfExceptionIfProxiedActionThowsException()
        {
            // Setup
            CruiseControlException e = new CruiseControlException("A nasty exception");

            actionMock.ExpectAndThrow("Execute", e, request);

            Hashtable expectedContext = new Hashtable();

            expectedContext["exception"] = e;
            velocityViewGeneratorMock.ExpectAndReturn("GenerateView", errorResponse, "ActionException.vm", new HashtableConstraint(expectedContext));

            // Execute & Verify
            Assert.AreEqual(errorResponse, exceptionCatchingAction.Execute(request));
            VerifyAll();
        }
        public void IsLoginOK_LoggerThrowsException_WritesToWebService()
        {
            DynamicMock stubLog     = new DynamicMock(typeof(ILogger));
            DynamicMock mockService = new DynamicMock(typeof(IWebService));

            stubLog.ExpectAndThrow("Write", new LoggerException("fake exception"), "yo");
            mockService.Expect("Write", "got exception");

            var loginManager =
                new LoginManagerWithMockAndStub((ILogger)stubLog.MockInstance,
                                                (IWebService)mockService.MockInstance);

            loginManager.IsLoginOK("", "");

            mockService.Verify();
        }
        public void ShouldHandleIncrementingLabelAfterInitialBuildFailsWithException()
        {
            IMock mockSourceControl = new DynamicMock(typeof(ISourceControl));

            mockSourceControl.ExpectAndThrow("GetModifications", new Exception("doh!"), new IsAnything(), new IsAnything());
            mockSourceControl.ExpectAndReturn("GetModifications", new Modification[] { new Modification() }, new IsAnything(), new IsAnything());

            Project project = new Project();

            project.Name          = "test";
            project.SourceControl = (ISourceControl)mockSourceControl.MockInstance;
            project.StateManager  = new StateManagerStub();
            try { project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null)); }
            catch (Exception) { }

            project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null));
            Assert.AreEqual(IntegrationStatus.Success, project.CurrentResult.Status);
            Assert.AreEqual("1", project.CurrentResult.Label);
        }
Exemple #11
0
    public RejectInvalidStateAbbreviation()
    {
        IMock mock = new DynamicMock(typeof(ITaxCalculator));

        mock.ExpectAndReturn("CalculateTax", 7.25, 100, "TX");
        mock.ExpectAndReturn("CalculateTax", 7.00, 100, "NC");
        mock.ExpectAndThrow("CalculateTax",
                            new ArgumentException(), 100, "XX");

        ITaxCalculator calc = mock.Object as ITaxCalculator;

        Assert.That(
            calc.CalculateTax(100, "TX"),
            Is.EqualTo(7.25)
            );
        Assert.That(
            calc.CalculateTax(100, "NC"),
            Is.EqualTo(7.00));

        calc.CalculateTax(100, "XX");
    }
        public void ShouldNotResetLabelIfGetModificationsThrowsException()
        {
            IMock mockSourceControl = new DynamicMock(typeof(ISourceControl));

            mockSourceControl.ExpectAndThrow("GetModifications", new Exception("doh!"), new IsAnything(), new IsAnything());
            mockSourceControl.ExpectAndReturn("GetModifications", new Modification[] { new Modification() }, new IsAnything(), new IsAnything());

            StateManagerStub stateManagerStub = new StateManagerStub();

            stateManagerStub.SaveState(IntegrationResultMother.CreateSuccessful("10"));

            Project project = new Project();

            project.Name          = "test";
            project.SourceControl = (ISourceControl)mockSourceControl.MockInstance;
            project.StateManager  = stateManagerStub;
            try { project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null)); }
            catch (Exception) { }

            project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test", null));
            Assert.AreEqual(IntegrationStatus.Success, project.CurrentResult.Status);
            Assert.AreEqual("11", project.CurrentResult.Label);
        }
 public void IgnoresExceptionAddingExistingApplication()
 {
     factoryMock.ExpectAndThrow("CreateApplicationWatcherMonitor", new Exception("exception generated to test behaviour adding application"));
     AddApplication();
     location = new FileSystemDeployLocation(new ForwardingDeployEventDispatcher(), factory, deployPath, true);
 }