public void ShouldOnlyBuildBetween7AMAnd7PMOnWeekdays() { FilterTrigger outerTrigger = new FilterTrigger((DateTimeProvider)mockDateTime.MockInstance); outerTrigger.StartTime = "19:00"; outerTrigger.EndTime = "7:00"; outerTrigger.InnerTrigger = trigger; trigger.StartTime = "0:00"; trigger.EndTime = "23:59:59"; trigger.WeekDays = new DayOfWeek[] { DayOfWeek.Saturday, DayOfWeek.Sunday }; IntegrationRequest request = ModificationExistRequest(); mockTrigger.SetupResult("Fire", request); mockDateTime.SetupResult("Now", new DateTime(2006, 8, 10, 11, 30, 0, 0)); // Thurs midday Assert.AreEqual(request, outerTrigger.Fire(), "outerTrigger.Fire()"); mockDateTime.SetupResult("Now", new DateTime(2006, 8, 10, 19, 30, 0, 0)); // Thurs evening Assert.IsNull(outerTrigger.Fire(), "outerTrigger.Fire()"); mockDateTime.SetupResult("Now", new DateTime(2006, 8, 12, 11, 30, 0, 0)); // Sat midday Assert.IsNull(outerTrigger.Fire(), "outerTrigger.Fire()"); mockDateTime.SetupResult("Now", new DateTime(2006, 8, 12, 19, 30, 0, 0)); // Sat evening Assert.IsNull(outerTrigger.Fire(), "outerTrigger.Fire()"); }
public void ShouldUseFilterEndTimeIfTriggerBuildTimeIsInFilter() { DateTime triggerNextBuildTime = new DateTime(2004, 12, 1, 10, 30, 00); mockTrigger.SetupResult("NextBuild", triggerNextBuildTime); Assert.AreEqual(new DateTime(2004, 12, 1, 11, 00, 00), trigger.NextBuild, "trigger.NextBuild"); }
public void Setup() { this.mocks = new MockRepository(); mockery = new Mockery(); targetMock = mockery.NewDynamicMock(typeof(IIntegrationRunnerTarget)); resultManagerMock = mockery.NewDynamicMock(typeof(IIntegrationResultManager)); quietPeriodMock = mockery.NewDynamicMock(typeof(IQuietPeriod)); runner = new IntegrationRunner((IIntegrationResultManager)resultManagerMock.MockInstance, (IIntegrationRunnerTarget)targetMock.MockInstance, (IQuietPeriod)quietPeriodMock.MockInstance); request = ModificationExistRequest(); endTime = new DateTime(2005, 2, 1); modifications = new Modification[] { new Modification() }; resultMock = mockery.NewDynamicMock(typeof(IIntegrationResult)); resultMock.SetupResult("WorkingDirectory", TempFileUtil.GetTempPath("workingDir")); resultMock.SetupResult("ArtifactDirectory", TempFileUtil.GetTempPath("artifactDir")); resultMock.SetupResult("BuildProgressInformation", new ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation("",string.Empty)); resultMock.SetupResult("IntegrationProperties", new Dictionary<string, string>()); result = (IIntegrationResult)resultMock.MockInstance; lastResultMock = mockery.NewDynamicMock(typeof(IIntegrationResult)); lastResult = (IIntegrationResult)lastResultMock.MockInstance; }
public void Setup() { this.mocks = new MockRepository(); mockery = new Mockery(); targetMock = mockery.NewDynamicMock(typeof(IIntegrationRunnerTarget)); resultManagerMock = mockery.NewDynamicMock(typeof(IIntegrationResultManager)); quietPeriodMock = mockery.NewDynamicMock(typeof(IQuietPeriod)); runner = new IntegrationRunner((IIntegrationResultManager)resultManagerMock.MockInstance, (IIntegrationRunnerTarget)targetMock.MockInstance, (IQuietPeriod)quietPeriodMock.MockInstance); request = ModificationExistRequest(); endTime = new DateTime(2005, 2, 1); modifications = new Modification[] { new Modification() }; resultMock = mockery.NewDynamicMock(typeof(IIntegrationResult)); resultMock.SetupResult("WorkingDirectory", TempFileUtil.GetTempPath("workingDir")); resultMock.SetupResult("ArtifactDirectory", TempFileUtil.GetTempPath("artifactDir")); resultMock.SetupResult("BuildProgressInformation", new ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation("", string.Empty)); resultMock.SetupResult("IntegrationProperties", new Dictionary <string, string>()); result = (IIntegrationResult)resultMock.MockInstance; lastResultMock = mockery.NewDynamicMock(typeof(IIntegrationResult)); lastResult = (IIntegrationResult)lastResultMock.MockInstance; }
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(); }
protected void SetUp() { mockFarmService = new DynamicMock(typeof(IFarmService)); mockRequest = new DynamicMock(typeof(ICruiseRequest)); serverSpecifier = new DefaultServerSpecifier("local"); mockRequest.SetupResult("ServerSpecifier", serverSpecifier); mockRequest.SetupResult("ProjectName", "test"); report = new ProjectXmlReport((IFarmService)mockFarmService.MockInstance, null); }
protected void SetUp() { mockFarmService = new DynamicMock(typeof (IFarmService)); mockRequest = new DynamicMock(typeof (ICruiseRequest)); serverSpecifier = new DefaultServerSpecifier("local"); mockRequest.SetupResult("ServerSpecifier", serverSpecifier); mockRequest.SetupResult("ProjectName", "test"); report = new ProjectXmlReport((IFarmService)mockFarmService.MockInstance, null); }
public void WhenTheBuildIsPerformedDuringANewIterationTheIterationNumberIsUpdatedAndTheLabelReset() { // Set the release start date needs to be 15 iterations ago // from today. So take today's date and remove 15 weeks and a couple more days. dateTimeMock.SetupResult("Today", DateTime.Today); labeller.ReleaseStartDate = DateTime.Today.AddDays(-(15 * 7 + 2)); // one week iterations labeller.Duration = 1; Assert.AreEqual("15.1", labeller.Generate(SuccessfulResult("14.35"))); }
// Limitations [Test] public void CannotOverrideNonVirtualFeatures() { cg = new ClassGenerator(typeof(AbstractThingy), mock); AbstractThingy s = (AbstractThingy)cg.Generate(); mock.SetupResult("NonVirtualMethod", "non virtual method"); mock.SetupResult("NonVirtualProperty", "non virtual property"); Assertion.AssertEquals("xx", s.NonVirtualMethod()); Assertion.AssertEquals("xx", s.NonVirtualProperty); mock.Verify(); }
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)); }
public void RandomRaining() { random.SetupResult("NextTemperature", 1.0); random.SetupResult("NextIsRaining", true); weather.Randomize(); Assertion.Assert("is raining", weather.IsRaining); }
public void SetUp() { dateTimeMock = new DynamicMock(typeof(DateTimeProvider)); dateTimeMock.SetupResult("Today", new DateTime(2005, 7, 20, 0, 0, 0, 0)); labeller = new IterationLabeller((DateTimeProvider)dateTimeMock.MockInstance); labeller.ReleaseStartDate = releaseStartDate; }
public void SetUp() { dateTimeMock = new DynamicMock(typeof (DateTimeProvider)); dateTimeMock.SetupResult("Today", new DateTime(2005, 7, 20, 0, 0, 0, 0)); labeller = new IterationLabeller((DateTimeProvider) dateTimeMock.MockInstance); labeller.ReleaseStartDate = releaseStartDate; }
public void Setup() { Source = "IntervalTrigger"; mockDateTime = new DynamicMock(typeof (DateTimeProvider)); initialDateTimeNow = new DateTime(2002, 1, 2, 3, 0, 0, 0); mockDateTime.SetupResult("Now", this.initialDateTimeNow); trigger = new IntervalTrigger((DateTimeProvider) mockDateTime.MockInstance); }
public void Setup() { Source = "IntervalTrigger"; mockDateTime = new DynamicMock(typeof(DateTimeProvider)); initialDateTimeNow = new DateTime(2002, 1, 2, 3, 0, 0, 0); mockDateTime.SetupResult("Now", this.initialDateTimeNow); trigger = new IntervalTrigger((DateTimeProvider)mockDateTime.MockInstance); }
public void SetUp() { Trace.Listeners.Clear(); mockArgs = new DynamicMock(typeof(IArgumentParser)); mockArgs.SetupResult("ConfigFile", "ccnet.config"); container = new ConsoleContainer((IArgumentParser)mockArgs.MockInstance); }
public void SetUp() { Trace.Listeners.Clear(); mockArgs = new DynamicMock(typeof(IArgumentParser)); mockArgs.SetupResult("ConfigFile", "ccnet.config"); container = new ConsoleContainer((IArgumentParser) mockArgs.MockInstance); }
public void SetUp() { // setup mock Order and populate with default return values. order = new DynamicMock(typeof(Order)); order.SetupResult("Amount", 1002.0); order.SetupResult("Urgent", false); order.SetupResult("Number", 123); order.SetupResult("User", "joe"); // create mock Notifier notifier = new DynamicMock(typeof(Notifier)); // create real OrderProcessor to be tested orderProcessor = new OrderProcessor(); // switch the OrderProcessor to use the mock Notifier orderProcessor.notifier = (Notifier)notifier.MockInstance; }
public void Setup() { Source = "UrlTrigger"; initialDateTimeNow = new DateTime(2002, 1, 2, 3, 0, 0, 0); mockDateTime = new DynamicMock(typeof (DateTimeProvider)); mockDateTime.SetupResult("Now", this.initialDateTimeNow); mockHttpWrapper = new DynamicMock(typeof (HttpWrapper)); trigger = new UrlTrigger((DateTimeProvider) mockDateTime.MockInstance, (HttpWrapper) mockHttpWrapper.MockInstance); trigger.Url = DefaultUrl; }
public void Setup() { Source = "UrlTrigger"; initialDateTimeNow = new DateTime(2002, 1, 2, 3, 0, 0, 0); mockDateTime = new DynamicMock(typeof(DateTimeProvider)); mockDateTime.SetupResult("Now", this.initialDateTimeNow); mockHttpWrapper = new DynamicMock(typeof(HttpWrapper)); trigger = new UrlTrigger((DateTimeProvider)mockDateTime.MockInstance, (HttpWrapper)mockHttpWrapper.MockInstance); trigger.Url = DefaultUrl; }
public void SetupResultWithWrongType() { try { full.SetupResult("Foo", true); Fail(); } catch (ArgumentException e) { AssertEquals("method <Foo> returns a System.String", e.Message); } }
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); }
public void SetUp() { CreateProcessExecutorMock(DEFAULT_SS_EXE_PATH); mockRegistry = new DynamicMock(typeof(IRegistry)); mockProcessExecutor.Strict = true; mockRegistry.SetupResult("GetExpectedLocalMachineSubKeyValue", DEFAULT_SS_EXE_PATH, typeof(string), typeof(string)); VssLocale locale = new VssLocale(CultureInfo.InvariantCulture); historyParser = new VssHistoryParser(locale); vss = new Vss(locale, historyParser, (ProcessExecutor) mockProcessExecutor.MockInstance, (IRegistry) mockRegistry.MockInstance); vss.Project = "$/fooProject"; vss.Culture = string.Empty; // invariant culture vss.Username = "******"; vss.Password = "******"; vss.WorkingDirectory = DefaultWorkingDirectory; today = DateTime.Now; yesterday = today.AddDays(-1); }
public void NotifyAnotherUserAnotherNumber() { // setup order.SetupResult("Number", 456); order.SetupResult("User", "chris"); notifier.Expect("NotifyUser", "chris", "Order 456 has been dispatched"); // execute orderProcessor.Process((Order)order.MockInstance); // verify notifier.Verify(); }
public void SetUp() { CreateProcessExecutorMock(DEFAULT_SS_EXE_PATH); mockRegistry = new DynamicMock(typeof(IRegistry)); mockProcessExecutor.Strict = true; mockRegistry.SetupResult("GetExpectedLocalMachineSubKeyValue", DEFAULT_SS_EXE_PATH, typeof(string), typeof(string)); VssLocale locale = new VssLocale(CultureInfo.InvariantCulture); historyParser = new VssHistoryParser(locale); vss = new Vss(locale, historyParser, (ProcessExecutor)mockProcessExecutor.MockInstance, (IRegistry)mockRegistry.MockInstance); vss.Project = "$/fooProject"; vss.Culture = string.Empty; // invariant culture vss.Username = "******"; vss.Password = "******"; vss.WorkingDirectory = DefaultWorkingDirectory; today = DateTime.Now; yesterday = today.AddDays(-1); }
public void VerifyThatShouldRequestIntegrationAfterTenSeconds() { trigger.IntervalSeconds = 10; trigger.BuildCondition = BuildCondition.IfModificationExists; mockDateTime.SetupResult("Now", new DateTime(2004, 1, 1, 1, 0, 0, 0)); Assert.AreEqual(ModificationExistRequest(), trigger.Fire(), "trigger.Fire()"); trigger.IntegrationCompleted(); mockDateTime.SetupResult("Now", new DateTime(2004, 1, 1, 1, 0, 5, 0)); // 5 seconds later Assert.IsNull(trigger.Fire(), "trigger.Fire()"); mockDateTime.SetupResult("Now", new DateTime(2004, 1, 1, 1, 0, 9, 0)); // 4 seconds later // still before 1sec Assert.IsNull(trigger.Fire(), "trigger.Fire()"); // sleep beyond the 1sec mark mockDateTime.SetupResult("Now", new DateTime(2004, 1, 1, 1, 0, 14, 0)); // 5 seconds later Assert.AreEqual(ModificationExistRequest(), trigger.Fire()); trigger.IntegrationCompleted(); Assert.IsNull(trigger.Fire(), "trigger.Fire()"); VerifyAll(); }
protected void SetUp() { projectSerializerMock = new DynamicMock(typeof(IProjectSerializer)); integratorMock1 = new DynamicMock(typeof(IProjectIntegrator)); integratorMock2 = new DynamicMock(typeof(IProjectIntegrator)); integratorMock3 = new DynamicMock(typeof(IProjectIntegrator)); integrator1 = (IProjectIntegrator)integratorMock1.MockInstance; integrator2 = (IProjectIntegrator)integratorMock2.MockInstance; integrator3 = (IProjectIntegrator)integratorMock3.MockInstance; integratorMock1.SetupResult("Name", "Project 1"); integratorMock2.SetupResult("Name", "Project 2"); integratorMock3.SetupResult("Name", "Project 3"); fileSystem = mocks.DynamicMock <IFileSystem>(); executionEnvironment = mocks.DynamicMock <IExecutionEnvironment>(); SetupResult.For(executionEnvironment.IsRunningOnWindows).Return(true); SetupResult.For(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).Return(applicationDataPath); SetupResult.For(fileSystem.DirectoryExists(applicationDataPath)).Return(true); mocks.ReplayAll(); integrationQueue = null; // We have no way of injecting currently. configuration = new Configuration(); project1 = new Project(); project1.Name = "Project 1"; integratorMock1.SetupResult("Project", project1); project2 = new Project(); project2.Name = "Project 2"; integratorMock2.SetupResult("Project", project1); mockProject = new DynamicMock(typeof(IProject)); mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProjectInstance = (IProject)mockProject.MockInstance; mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("StartupMode", ProjectStartupMode.UseLastState); integratorMock3.SetupResult("Project", mockProjectInstance); configuration.AddProject(project1); configuration.AddProject(project2); configuration.AddProject(mockProjectInstance); integratorList = new ProjectIntegratorList(); integratorList.Add(integrator1); integratorList.Add(integrator2); integratorList.Add(integrator3); configServiceMock = new DynamicMock(typeof(IConfigurationService)); configServiceMock.ExpectAndReturn("Load", configuration); projectIntegratorListFactoryMock = new DynamicMock(typeof(IProjectIntegratorListFactory)); projectIntegratorListFactoryMock.ExpectAndReturn("CreateProjectIntegrators", integratorList, configuration.Projects, integrationQueue); stateManagerMock = new DynamicMock(typeof(IProjectStateManager)); stateManagerMock.SetupResult("CheckIfProjectCanStart", true, typeof(string)); server = new CruiseServer((IConfigurationService)configServiceMock.MockInstance, (IProjectIntegratorListFactory)projectIntegratorListFactoryMock.MockInstance, (IProjectSerializer)projectSerializerMock.MockInstance, (IProjectStateManager)stateManagerMock.MockInstance, fileSystem, executionEnvironment, null); }
public void ShouldRunIntegrationIfCalendarTimeIsAfterIntegrationTime() { mockDateTime.SetupResult("Now", new DateTime(2004, 1, 1, 23, 25, 0, 0)); trigger.Time = "23:30"; trigger.BuildCondition = BuildCondition.IfModificationExists; Assert.IsNull(trigger.Fire()); mockDateTime.SetupResult("Now", new DateTime(2004, 1, 1, 23, 31, 0, 0)); Assert.AreEqual(ModificationExistRequest(), trigger.Fire()); }
protected void SetUp() { projectSerializerMock = new DynamicMock(typeof (IProjectSerializer)); integratorMock1 = new DynamicMock(typeof (IProjectIntegrator)); integratorMock2 = new DynamicMock(typeof (IProjectIntegrator)); integratorMock3 = new DynamicMock(typeof (IProjectIntegrator)); integrator1 = (IProjectIntegrator) integratorMock1.MockInstance; integrator2 = (IProjectIntegrator) integratorMock2.MockInstance; integrator3 = (IProjectIntegrator) integratorMock3.MockInstance; integratorMock1.SetupResult("Name", "Project 1"); integratorMock2.SetupResult("Name", "Project 2"); integratorMock3.SetupResult("Name", "Project 3"); fileSystem = mocks.DynamicMock<IFileSystem>(); executionEnvironment = mocks.DynamicMock<IExecutionEnvironment>(); SetupResult.For(executionEnvironment.IsRunningOnWindows).Return(true); SetupResult.For(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).Return(applicationDataPath); SetupResult.For(fileSystem.DirectoryExists(applicationDataPath)).Return(true); mocks.ReplayAll(); integrationQueue = null; // We have no way of injecting currently. configuration = new Configuration(); project1 = new Project(); project1.Name = "Project 1"; integratorMock1.SetupResult("Project", project1); project2 = new Project(); project2.Name = "Project 2"; integratorMock2.SetupResult("Project", project1); mockProject = new DynamicMock(typeof(IProject)); mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProject.SetupResult("QueueName", "Project 3"); mockProjectInstance = (IProject)mockProject.MockInstance; mockProject.SetupResult("Name", "Project 3"); mockProject.SetupResult("StartupMode", ProjectStartupMode.UseLastState); integratorMock3.SetupResult("Project", mockProjectInstance); configuration.AddProject(project1); configuration.AddProject(project2); configuration.AddProject(mockProjectInstance); integratorList = new ProjectIntegratorList(); integratorList.Add(integrator1); integratorList.Add(integrator2); integratorList.Add(integrator3); configServiceMock = new DynamicMock(typeof (IConfigurationService)); configServiceMock.ExpectAndReturn("Load", configuration); projectIntegratorListFactoryMock = new DynamicMock(typeof (IProjectIntegratorListFactory)); projectIntegratorListFactoryMock.ExpectAndReturn("CreateProjectIntegrators", integratorList, configuration.Projects, integrationQueue); stateManagerMock = new DynamicMock(typeof(IProjectStateManager)); stateManagerMock.SetupResult("CheckIfProjectCanStart", true, typeof(string)); server = new CruiseServer((IConfigurationService) configServiceMock.MockInstance, (IProjectIntegratorListFactory) projectIntegratorListFactoryMock.MockInstance, (IProjectSerializer) projectSerializerMock.MockInstance, (IProjectStateManager)stateManagerMock.MockInstance, fileSystem, executionEnvironment, null); }