コード例 #1
0
        public void ShouldInvokeDecoratedTriggerWhenTimeIsOutsideOfRange()
        {
            mockTrigger.ExpectAndReturn("Fire", ModificationExistRequest());
            mockDateTime.ExpectAndReturn("Now", new DateTime(2004, 12, 1, 11, 30, 0, 0));

            Assert.AreEqual(ModificationExistRequest(), trigger.Fire(), "trigger.Fire()");
        }
コード例 #2
0
 public void ShouldBuildAfterFirstInterval()
 {
     mockDateTime.SetupResult("Now", initialDateTimeNow.AddSeconds(trigger.IntervalSeconds));
     mockHttpWrapper.ExpectAndReturn("GetLastModifiedTimeFor", initialDateTimeNow, new Uri(DefaultUrl), DateTime.MinValue);
     Assert.AreEqual(ModificationExistRequest(), trigger.Fire(), "trigger.Fire()");
     VerifyAll();
 }
コード例 #3
0
        public void InitialBuildShouldBeForced()
        {
            mockStateManager.ExpectAndReturn("HasPreviousState", false, "project");

            IIntegrationResult expected = manager.StartNewIntegration(ModificationExistRequest());

            Assert.AreEqual(BuildCondition.ForceBuild, expected.BuildCondition);
        }
コード例 #4
0
        public void CreateLocalCruiseServer()
        {
            mockArgs.ExpectAndReturn("IsRemote", false);

            ICruiseServer server = container.CreateServer();

            Assert.AreEqual(typeof(CruiseServer), server.GetType());
        }
コード例 #5
0
        public void ShouldNotInvokeDecoratedTriggerWhenTimeAndWeekDayMatch()
        {
            mockTrigger.ExpectNoCall("Fire");
            mockDateTime.ExpectAndReturn("Now", new DateTime(2004, 12, 1, 10, 30, 0, 0));

            Assert.IsNull(trigger.Fire(), "trigger.Fire()");
        }
コード例 #6
0
 private void SetupPreambleExpections()
 {
     targetMock.Expect("Activity", ProjectActivity.CheckingModifications);
     resultManagerMock.ExpectAndReturn("StartNewIntegration", result, request);
     resultMock.Expect("MarkStartTime");
     resultManagerMock.ExpectAndReturn("LastIntegrationResult", lastResult);
     sourceControlMock        = new DynamicMock(typeof(ISourceControl));
     sourceControlMock.Strict = true;
     targetMock.SetupResult("SourceControl", sourceControlMock.MockInstance);
     quietPeriodMock.ExpectAndReturn("GetModifications", modifications, sourceControlMock.MockInstance, lastResult, result);
     resultMock.ExpectAndReturn("Modifications", modifications);
 }
コード例 #7
0
        public void ShouldCloneIfDirectoryDoesntExist()
        {
            setupGit((IFileSystem)mockFileSystem.MockInstance);

            mockFileSystem.ExpectAndReturn("DirectoryExists", false, @"c:\source\");

            ExpectToExecuteArguments(GIT_CLONE);

            ExpectToExecuteArguments(GIT_REMOTE_COMMITS);

            git.GetModifications(IntegrationResult(from), IntegrationResult(to));
        }
コード例 #8
0
        public void CommitTransactionHappyPath()
        {
            beginTransaction();

            _transactionMock.Expect("Commit");
            _connectionMock.Expect("Close");
            _connectionMock.ExpectAndReturn("State", ConnectionState.Open);

            _executionState.CommitTransaction();

            _transactionMock.Verify();
            _connectionMock.Verify();
        }
コード例 #9
0
        public void ExecuteNUnitConsoleAndRetrieveResultsFromFile()
        {
            string      args = string.Format(@"/xml={0} /nologo foo.dll", GeneratePath("{0}", task.OutputFile));
            ProcessInfo info = new ProcessInfo(NUnitConsolePath, args, WORKING_DIRECTORY);

            info.TimeOut = NUnitTask.DefaultTimeout * 1000;
            executorMock.ExpectAndReturn("Execute", new ProcessResult("", String.Empty, 0, false), new object[] { info });

            task.Run(result);

            Assert.AreEqual("foo", result.TaskOutput);
            executorMock.Verify();
        }
コード例 #10
0
        public void GetModificationsWhenApplyLabelIsDisabledDoesNotCreateLabels()
        {
            ProcessResult result = new ProcessResult("", string.Empty, 0, false);

            Modification[] dummyArray = new Modification[1] {
                new Modification()
            };
            _historyParser.SetupResult("Parse", dummyArray, typeof(TextReader), typeof(DateTime), typeof(DateTime));
            _executor.ExpectAndReturn("Execute", result, new IsTypeOf(typeof(ProcessInfo)));
            _executor.ExpectNoCall("Execute", typeof(ProcessInfo));

            _vss.GetModifications(IntegrationResultMother.CreateSuccessful(DateTime.Now), IntegrationResultMother.CreateSuccessful(DateTime.Now));
        }
コード例 #11
0
        public void GenerateXmlContentForSpecifiedProject()
        {
            ProjectStatusOnServer status  = new ProjectStatusOnServer(ProjectStatusFixture.New("wrong"), serverSpecifier);
            ProjectStatusOnServer status2 = new ProjectStatusOnServer(ProjectStatusFixture.New("test"), serverSpecifier);

            mockFarmService.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions", ProjectStatusList(status, status2), null);

            IResponse response = report.Execute((ICruiseRequest)mockRequest.MockInstance);

            Assert.IsInstanceOfType(typeof(XmlFragmentResponse), response);
            string xml = ((XmlFragmentResponse)response).ResponseFragment;

            XPathAssert.Matches(XPathAssert.LoadAsDocument(xml), "/CruiseControl/Projects/Project/@name", "test");
        }
コード例 #12
0
        public void ShouldCloneIfDirectoryDoesNotExist()
        {
            mockFileSystem.ExpectAndReturn("DirectoryExists", false, DefaultWorkingDirectory);
            ExpectCloneAndInitialiseRepository();

            ExpectToExecuteArguments(GIT_LOG_REMOTE_COMMITS);
            ExpectLogRemoteHead(TO_COMMIT);
            mockHistoryParser.ExpectAndReturn("Parse", new Modification[] { }, new IsAnything(), new IsAnything(), new IsAnything());

            IIntegrationResult to = IntegrationResult();

            git.GetModifications(IntegrationResult(FROM_COMMIT), to);

            AssertIntegrationResultTaggedWithCommit(to, TO_COMMIT);
        }
コード例 #13
0
        public void WhenThereIsAModificationWithinTheDelayPeriodSleepsUntilTheEndOfThePeriodAndTriesAgain()
        {
            quietPeriod.ModificationDelaySeconds = 45;

            // last build was at 12:01:00, current build is at 12:02:00, modification at 12:01:30
            mockSourceControl.ExpectAndReturn("GetModifications", mods, lastBuild, thisBuild);
            mockDateTimeProvider.Expect("Sleep", TimeSpan.FromSeconds(15));

            mockDateTimeProvider.ExpectAndReturn("Now", CreateDateTime(12, 02, 15));
            mockSourceControl.ExpectAndReturn("GetModifications", mods, lastBuild, IntegrationResultMother.CreateSuccessful(CreateDateTime(12, 02, 15)));

            Modification[] actualMods = quietPeriod.GetModifications((ISourceControl)mockSourceControl.MockInstance, lastBuild, thisBuild);

            Assert.AreEqual(mods, actualMods);
        }
コード例 #14
0
        public void CanExecuteHasChanges()
        {
            InitialiseAlienbrain();
            ProcessInfo expectedProcessRequest = new ProcessInfo(EXECUTABLE, string.Format(Alienbrain.GET_COMMAND_TEMPLATE,
                                                                                           PROJECT_PATH,
                                                                                           SERVER,
                                                                                           DATABASE,
                                                                                           USER,
                                                                                           PASSWORD,
                                                                                           WORKDIR_PATH));

            expectedProcessRequest.TimeOut = Timeout.DefaultTimeout.Millis;

            executor.ExpectAndReturn("Execute", new ProcessResult("foo", null, 0, false), expectedProcessRequest);
            Assert.IsTrue(alienbrain.HasChanges(expectedProcessRequest));
            executor.Verify();
        }
コード例 #15
0
        public void ShouldLoadIntegrationResultFromStateManagerAndReturnLastSuccessfulBuildLabel()
        {
            mockStateManager.ExpectAndReturn("LoadState", SuccessfulResult("success"), "Project1");
            labeller.Project = "Project1";

            Assert.AreEqual("success", labeller.Generate(new IntegrationResult()));
            mockStateManager.Verify();
        }
コード例 #16
0
        public void ShouldCreateWorkingDirectoryIfItDoesntExistOrIsNotARepository()
        {
            hg = new Mercurial((IHistoryParser)mockHistoryParser.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance,
                               (IFileSystem)mockFileSystem.MockInstance, (IFileDirectoryDeleter)mockFileDirectoryDeleter.MockInstance);
            hg.WorkingDirectory = tempWorkDir;
            hg.Repository       = @"C:\foo";

            mockFileSystem.Expect("EnsureFolderExists", tempWorkDir);
            mockFileSystem.Expect("EnsureFolderExists", tempHgDir);
            mockFileSystem.ExpectAndReturn("DirectoryExists", true, tempWorkDir);
            mockFileSystem.ExpectAndReturn("DirectoryExists", false, tempHgDir);
            mockFileDirectoryDeleter.Expect("DeleteIncludingReadOnlyObjects", new object[] { tempWorkDir });
            mockFileSystem.ExpectAndReturn("DirectoryExists", false, tempWorkDir);
            ExpectToExecuteArguments(@"init " + StringUtil.AutoDoubleQuoteString(tempWorkDir), Directory.GetParent(Path.GetFullPath(tempWorkDir)).FullName);
            ExpectToExecuteArguments(@"pull C:\foo", tempWorkDir);

            hg.GetModifications(IntegrationResult(from), IntegrationResult(to));
        }
コード例 #17
0
        public void GetModifications()
        {
            mockExecutor.ExpectAndReturn("Execute", ProcessResultFixture.CreateSuccessfulResult(), new IsAnything());
            mockParser.ExpectAndReturn("Parse", new Modification[] { new Modification(), new Modification() }, new IsAnything(), new IsAnything(), new IsAnything());

            Modification[] mods = pvcs.GetModifications(IntegrationResultMother.CreateSuccessful(new DateTime(2004, 6, 1, 1, 1, 1)),
                                                        IntegrationResultMother.CreateSuccessful(new DateTime(2004, 6, 1, 2, 2, 2)));
            Assert.AreEqual(2, mods.Length);
        }
コード例 #18
0
		protected void SetUp()
		{
			mockCruiseManager = new DynamicMock(typeof (ICruiseManager));
			mockCruiseManager.ExpectAndReturn("GetProjectStatus", new ProjectStatus[1] {NewProjectStatus("foo", "1")});

			mockRemotingService = new DynamicMock(typeof (IRemotingService));
			mockRemotingService.ExpectAndReturn("Connect", mockCruiseManager.MockInstance, typeof (ICruiseManager), RemoteCruiseServer.DefaultManagerUri);

			labeller = new RemoteProjectLabeller((IRemotingService) mockRemotingService.MockInstance);
		}
コード例 #19
0
        public void ShouldBuildUrlIfUrlBuilderSpecified()
        {
            IMock mockUrlBuilder = new DynamicMock(typeof(IModificationUrlBuilder));

            Modification[] modifications = new Modification[2] {
                new Modification(), new Modification()
            };
            hg.UrlBuilder = (IModificationUrlBuilder)mockUrlBuilder.MockInstance;

            mockProcessExecutor.ExpectAndReturn("Execute", new ProcessResult("", "", 0, false), new IsAnything());
            mockProcessExecutor.ExpectAndReturn("Execute", new ProcessResult("3", "", 0, false), new IsAnything());
            mockProcessExecutor.ExpectAndReturn("Execute", new ProcessResult("4", "", 0, false), new IsAnything());
            mockHistoryParser.ExpectAndReturn("Parse", modifications, new IsAnything(), new IsAnything(), new IsAnything());
            mockUrlBuilder.ExpectAndReturn("SetupModification", modifications, new object[] { modifications });

            Modification[] result = hg.GetModifications(IntegrationResult(from), IntegrationResult(to));
            Assert.That(result, Is.EqualTo(modifications));
            mockUrlBuilder.Verify();
        }
コード例 #20
0
ファイル: SvnTest.cs プロジェクト: robrich/CruiseControl.NET
        public void ShouldGetModificationsEvenWhenTrunkUrlIsNull()
        {
            svn.TrunkUrl = null;
            mockHistoryParser.ExpectAndReturn("Parse", new Modification[0], new IsAnything(), new IsAnything(), new IsAnything());
            ExpectToExecuteArguments("log -r \"{2001-01-21T20:00:00Z}:{2001-01-21T20:30:50Z}\" --verbose --xml --no-auth-cache --non-interactive");

            Modification[] modifications = svn.GetModifications(IntegrationResult(from), IntegrationResult(to));

            Assert.AreEqual(new Modification[0], modifications);
        }
コード例 #21
0
        public void ShouldCheckoutOnWorkingDictionaryWithSpaces()
        {
            var lastDirectorySeparatorIndex = DefaultWorkingDirectoryWithSpaces.TrimEnd().TrimEnd(Path.DirectorySeparatorChar).LastIndexOf(Path.DirectorySeparatorChar);
            var checkoutWd  = DefaultWorkingDirectoryWithSpaces.Substring(0, lastDirectorySeparatorIndex);
            var checkoutDir = DefaultWorkingDirectoryWithSpaces.Substring(lastDirectorySeparatorIndex).Trim(Path.DirectorySeparatorChar);

            ExpectToExecuteArguments(
                string.Format(
                    @"-d :pserver:[email protected]:/cvsroot/ccnet -q checkout -R -P -r branch -d {0} ccnet",
                    StringUtil.AutoDoubleQuoteString(checkoutDir)), checkoutWd);

            mockFileSystem.ExpectAndReturn("DirectoryExists", false, Path.Combine(DefaultWorkingDirectoryWithSpaces, "CVS"));

            cvs.CvsRoot          = ":pserver:[email protected]:/cvsroot/ccnet";
            cvs.Module           = "ccnet";
            cvs.AutoGetSource    = true;
            cvs.Branch           = "branch";
            cvs.WorkingDirectory = DefaultWorkingDirectoryWithSpaces;
            cvs.GetSource(IntegrationResult());
        }
コード例 #22
0
        protected void SetUp()
        {
            mockCruiseManager = new DynamicMock(typeof(ICruiseManager));
            mockCruiseManager.ExpectAndReturn("GetProjectStatus", new ProjectStatus[1] {
                NewProjectStatus("foo", "1")
            });

            mockRemotingService = new DynamicMock(typeof(IRemotingService));
            mockRemotingService.ExpectAndReturn("Connect", mockCruiseManager.MockInstance, typeof(ICruiseManager), RemoteCruiseServer.DefaultManagerUri);

            labeller = new RemoteProjectLabeller((IRemotingService)mockRemotingService.MockInstance);
        }
コード例 #23
0
        public void SetUp()
        {
            _connectionMock = new DynamicMock(typeof(IDbConnection));
            _connectionMock.ExpectAndReturn("State", ConnectionState.Closed);
            _commandMock = new DynamicMock(typeof(IDbCommand));

            _connection     = (IDbConnection)_connectionMock.MockInstance;
            _executionState = new TransactionalExecutionState(_connection);

            _transactionMock = new DynamicMock(typeof(IDbTransaction));
            _transaction     = (IDbTransaction)_transactionMock.MockInstance;
        }
コード例 #24
0
        public void ExecuteHappyPath()
        {
            _commandMock.Expect("Connection", _connection);
            _commandMock.ExpectAndReturn("ExecuteNonQuery", 1);
            _commandMock.Expect("Connection", new IsNull());
            _connectionMock.Strict = true;             // no calls to connection.


            int recordCount = _executionState.Execute((IDbCommand)_commandMock.MockInstance);

            Assert.AreEqual(1, recordCount);

            _commandMock.Verify();
            _connectionMock.Verify();
        }
コード例 #25
0
        public void BuildCommandLine()
        {
            string expectedArgs = @"/B /S /Vvar1=value1;var2=""value 2"" /P" + StringUtil.AutoDoubleQuoteString(Path.Combine(DefaultWorkingDirectory, "TestProject.fbz5"));

            ExpectToExecuteArguments(expectedArgs);

            _mockRegistry.ExpectAndReturn("GetLocalMachineSubKeyValue", Path.Combine(DefaultWorkingDirectory, "FinalBuilder5.exe"), @"SOFTWARE\VSoft\FinalBuilder\5.0", "Location");

            _task.FBVariables    = new FBVariable[2];
            _task.FBVariables[0] = new FBVariable("var1", "value1");
            _task.FBVariables[1] = new FBVariable("var2", "value 2");
            _task.ProjectFile    = Path.Combine(DefaultWorkingDirectory, "TestProject.fbz5");
            _task.ShowBanner     = false;
            _task.DontWriteToLog = true;
            _task.Timeout        = 600;
            _task.Run(_result);

            Assert.AreEqual(1, _result.TaskResults.Count);
            Assert.AreEqual(IntegrationStatus.Success, _result.Status);
            Assert.AreEqual(ProcessResultOutput, _result.TaskOutput);
        }
コード例 #26
0
        public void ExecuteHappyPath()
        {
            _connectionMock.Expect("Open");
            _commandMock.Expect("Connection", _connectionMock.MockInstance);
            _commandMock.ExpectAndReturn("ExecuteNonQuery", 1);
            _commandMock.Expect("Connection", new IsNull());
            _connectionMock.Expect("Close");

            IDbCommand command     = (IDbCommand)_commandMock.MockInstance;
            int        recordCount = _executionState.Execute(command);

            Assert.AreEqual(1, recordCount);

            _commandMock.Verify();
            _connectionMock.Verify();
        }
コード例 #27
0
        public void ShouldCloneIfDirectoryDoesntExist()
        {
            mockFileSystem.ExpectAndReturn("DirectoryExists", false, DefaultWorkingDirectory);

            ExpectToExecuteArguments(string.Concat(GIT_CLONE, " ", StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory)), Path.GetDirectoryName(DefaultWorkingDirectory.TrimEnd(Path.DirectorySeparatorChar)));

            ExpectToExecuteArguments("config --get user.name");
            ExpectToExecuteArguments("config --get user.email");

            ExpectToExecuteArguments("log origin/master --date-order -1 --pretty=format:\"%H\"");

            ExpectToExecuteArguments(GIT_REMOTE_COMMITS);

            git.GetModifications(IntegrationResult(from), IntegrationResult(to));
        }
コード例 #28
0
        public void ShouldReturnModificationsWhenHashsDifferent()
        {
            Modification[] modifications = new Modification[2] {
                new Modification(), new Modification()
            };

            ExpectToExecuteArguments(GIT_FETCH);

            ExpectToExecuteWithArgumentsAndReturn(GIT_REMOTE_HASH, new ProcessResult("abcdef", "", 0, false));
            ExpectToExecuteWithArgumentsAndReturn(GIT_LOCAL_HASH, new ProcessResult("ghijkl", "", 0, false));

            ExpectToExecuteArguments(GIT_REMOTE_COMMITS);

            mockHistoryParser.ExpectAndReturn("Parse", modifications, new IsAnything(), from, new IsAnything());

            Modification[] result = git.GetModifications(IntegrationResult(from), IntegrationResult(to));
            Assert.AreEqual(modifications, result);
        }
コード例 #29
0
        public void ShouldPopulateCorrectlyFromMinimalXml()
        {
            NetReflector.Read(ALIENBRAIN_XML_MINIMAL, alienbrain);

            // Get Default Executable from registry
            registry.ExpectAndReturn("GetExpectedLocalMachineSubKeyValue", INSTALLDIR, Alienbrain.AB_REGISTRY_PATH, Alienbrain.AB_REGISTRY_KEY);
            alienbrain.Executable = string.Empty;

            Assert.AreEqual(INSTALLDIR + "\\" + Alienbrain.AB_COMMMAND_PATH + "\\" + Alienbrain.AB_EXE, alienbrain.Executable);
            Assert.AreEqual(SERVER, alienbrain.Server);
            Assert.AreEqual(DATABASE, alienbrain.Database);
            Assert.AreEqual(USER, alienbrain.Username);
            Assert.AreEqual(PASSWORD, alienbrain.Password.PrivateValue);
            Assert.AreEqual(PROJECT_PATH, alienbrain.Project);
            Assert.AreEqual(string.Empty, alienbrain.WorkingDirectory);
            Assert.AreEqual(string.Empty, alienbrain.Branch);
            Assert.AreEqual(Convert.ToBoolean(true), alienbrain.AutoGetSource);
            Assert.AreEqual(Convert.ToBoolean(false), alienbrain.LabelOnSuccess);
        }
コード例 #30
0
 public void ReadDefaultExecutableFromRegistry()
 {
     mockRegistry.ExpectAndReturn("GetExpectedLocalMachineSubKeyValue", @"C:\Program Files\Microsoft Visual Studio\VSS\win32\SSSCC.DLL", Vss.SS_REGISTRY_PATH, Vss.SS_REGISTRY_KEY);
     Assert.AreEqual(@"C:\Program Files\Microsoft Visual Studio\VSS\win32\ss.exe", vss.Executable);
 }
コード例 #31
0
        public void SetUp()
        {
            _connectionMock = new DynamicMock(typeof(IDbConnection));
            _connectionMock.ExpectAndReturn("State", ConnectionState.Closed);
            _commandMock = new DynamicMock(typeof(IDbCommand));

            _connection = (IDbConnection) _connectionMock.MockInstance;
            _executionState = new TransactionalExecutionState(_connection);

            _transactionMock = new DynamicMock(typeof(IDbTransaction));
            _transaction = (IDbTransaction) _transactionMock.MockInstance;
        }
コード例 #32
0
 protected void ExpectToExecute(ProcessInfo processInfo)
 {
     mockProcessExecutor.ExpectAndReturn("Execute", SuccessfulProcessResult(), processInfo);
 }