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 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 ShouldNotResetLabelIfGetModificationsThrowsException()
        {
            var          mockSourceControl = new Mock <ISourceControl>();
            MockSequence sequence          = new MockSequence();

            mockSourceControl.InSequence(sequence).Setup(sourceControl => sourceControl.GetModifications(It.IsAny <IIntegrationResult>(), It.IsAny <IIntegrationResult>())).Throws(new Exception("doh!")).Verifiable();
            mockSourceControl.InSequence(sequence).Setup(sourceControl => sourceControl.GetModifications(It.IsAny <IIntegrationResult>(), It.IsAny <IIntegrationResult>())).Returns(new Modification[] { new Modification() }).Verifiable();

            StateManagerStub stateManagerStub = new StateManagerStub();

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

            Project project = new Project();

            project.Name          = "test";
            project.SourceControl = (ISourceControl)mockSourceControl.Object;
            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);
        }