public InvokeStatusChecked ( BuildStatus args ) : void | ||
args | BuildStatus | |
Résultat | void |
public void BuildStatusChanged_InProgressBuilds_DoSync() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Settings.SosOnlineAlwaysSync = true; rulesEngine.Settings.SosOnlineWhatToSync = WhatToSyncEnum.BuildStatuses; rulesEngine.Settings.SosOnlineUsername = "******"; var mock = new Mock<SosOnlineService>(); rulesEngine.SosOnlineService = mock.Object; rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); mock.Verify(i => i.BuildStatusChanged(It.IsAny<SirenOfShameSettings>(), It.IsAny<IList<BuildStatus>>(), It.IsAny<List<InstanceUserDto>>()), Times.Exactly(2)); }
public void Synchronize_ICheckInWithAlwaysSyncSetting_SosOnlineServiceSynchronize() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Settings.SosOnlineAlwaysSync = true; rulesEngine.Settings.SosOnlineUsername = "******"; rulesEngine.Settings.MyRawName = RulesEngineWrapper.CURRENT_USER; var sosOnlineService = new Mock<SosOnlineService>(); sosOnlineService.Setup(i => i.Synchronize(It.IsAny<SirenOfShameSettings>(), "633979044610000000,633979050100000000,1", null, It.IsAny<Action<DateTime>>(), It.IsAny<Action<String, ServerUnavailableException>>())) .Verifiable(); rulesEngine.SosOnlineService = sosOnlineService.Object; rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); sosOnlineService.Verify(); }
public void BuildStatusChanged_MyPointAndAchievementsOnly_DoesNotSync() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Settings.SosOnlineAlwaysSync = true; rulesEngine.Settings.SosOnlineWhatToSync = WhatToSyncEnum.MyPointAndAchievementsOnly; rulesEngine.Settings.SosOnlineUsername = "******"; var mock = new Mock<SosOnlineService>(); rulesEngine.SosOnlineService = mock.Object; rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); mock.Verify(i => i.BuildStatusChanged(It.IsAny<SirenOfShameSettings>(), It.IsAny<IList<BuildStatus>>(), It.IsAny<List<InstanceUserDto>>()), Times.Never()); }
public void BreakThenFixesBuild_UserHasStatsUpdated() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); // it should ignore initial states rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(1, rulesEngine.Settings.People.Count); Assert.AreEqual(1, rulesEngine.Settings.People[0].TotalBuilds); Assert.AreEqual(1, rulesEngine.Settings.People[0].FailedBuilds); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); Assert.AreEqual(1, rulesEngine.Settings.People[0].TotalBuilds); Assert.AreEqual(1, rulesEngine.Settings.People[0].FailedBuilds); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(2, rulesEngine.Settings.People[0].TotalBuilds); Assert.AreEqual(1, rulesEngine.Settings.People[0].FailedBuilds); }
public void BuidFailsForMyBuild_OneAlert() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildFailed, AlertType = AlertType.ModalDialog, BuildDefinitionId = RulesEngineWrapper.BUILD1_ID }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(1, rulesEngine.ModalDialogEvents.Count); }
public void BuidFailsForSomeOtherBuild_NoAlert() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildFailed, AlertType = AlertType.ModalDialog, BuildDefinitionId = "SomeOtherBuild" }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(0, rulesEngine.ModalDialogEvents.Count); }
public void InProgressDoesNotWrite() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); // do not write initial states rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); var lines = rulesEngine.SosDb.ReadAll(RulesEngineWrapper.BUILD1_ID); Assert.AreEqual(1, lines.Count); var buildDefinition = lines.First(); Assert.AreEqual("User1", buildDefinition.RequestedBy); Assert.AreEqual(new DateTime(2010, 1, 1, 1, 1, 1), buildDefinition.StartedTime); Assert.AreEqual(new DateTime(2010, 1, 1, 1, 10, 10), buildDefinition.FinishedTime); Assert.AreEqual(null, buildDefinition.Comment); Assert.AreEqual(BuildStatusEnum.Broken, buildDefinition.BuildStatusEnum); }
public void InitialStatusChecked_RefreshStatus() { var rulesEngine = new RulesEngineWrapper(); Assert.AreEqual(1, rulesEngine.RefreshStatusEvents.Count); var startedTime = new DateTime(2010, 1, 2, 1, 1, 1); var finishedTime = new DateTime(2010, 1, 2, 1, 2, 2); rulesEngine.InvokeStatusChecked(new[] { new BuildStatus { BuildStatusEnum = BuildStatusEnum.Working, Name = "Build Def 1", RequestedBy = "User1", BuildDefinitionId = "Build Def 1", StartedTime = startedTime, FinishedTime = finishedTime }, }); Assert.AreEqual(2, rulesEngine.RefreshStatusEvents.Count); Assert.AreEqual(1, rulesEngine.RefreshStatusEvents[1].BuildStatusDtos.Count()); BuildStatusDto buildStatus = rulesEngine.RefreshStatusEvents[1].BuildStatusDtos.First(); Assert.AreEqual((int)BallsEnum.Green, buildStatus.ImageIndex); Assert.AreEqual("Build Def 1", buildStatus.BuildDefinitionDisplayName); Assert.AreEqual("User1", buildStatus.RequestedByRawName); Assert.AreEqual("Build Def 1", buildStatus.BuildDefinitionId); Assert.AreEqual(BuildStatus.FormatAsDayMonthTime(startedTime), buildStatus.StartTimeShort); Assert.AreEqual("1:01", buildStatus.Duration); }
public void BuildInProgressThenPassThenInProgressWithGlobalBuildTriggeredRule_TwoAlerts() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildTriggered, AlertType = AlertType.TrayAlert }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); Assert.AreEqual(2, rulesEngine.TrayNotificationEvents.Count); Assert.AreEqual(rulesEngine.TrayNotificationEvents[0].Title, rulesEngine.TrayNotificationEvents[1].Title); }
public void ServerUnavailableThenAvailableThenUnavailable_TwoUnavailableTrayNotificationSent() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeServerUnavailable(new ServerUnavailableException("The network is down.")); rulesEngine.InvokeStatusChecked(new BuildStatus[] { }); rulesEngine.InvokeServerUnavailable(new ServerUnavailableException("The network is down.")); Assert.AreEqual(3, rulesEngine.TrayNotificationEvents.Count); Assert.AreEqual(2, rulesEngine.TrayNotificationEvents.Where(tn => tn.Title == "Build Server Unavailable").Count ()); }
public void NewBuildWithNewRequestedBy_PersonAdded() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.InitialFailedBuild, AlertType = AlertType.NoAlert, }); Assert.AreEqual(0, rulesEngine.Settings.CiEntryPointSettings[0].BuildDefinitionSettings[0].People.Count); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(1, rulesEngine.Settings.CiEntryPointSettings[0].BuildDefinitionSettings[0].People.Count); Assert.AreEqual(RulesEngineWrapper.CURRENT_USER, rulesEngine.Settings.CiEntryPointSettings[0].BuildDefinitionSettings[0].People[0]); }
public void IsBuildingWithBuildTriggeredRuleToStopOnSuccess_BuildSucceeds_LedsStop() { var rulesEngine = new RulesEngineWrapper(); var ledPattern = new LedPattern { Id = 2, Name = "Sally" }; rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildTriggered, LedPattern = ledPattern, LightsDuration = null, }); Assert.AreEqual(0, rulesEngine.SetLightsEvents.Count); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(0, rulesEngine.SetLightsEvents.Count); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); Assert.AreEqual(1, rulesEngine.SetLightsEvents.Count); Assert.AreEqual("Sally", rulesEngine.SetLightsEvents[0].LedPattern.Name); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(2, rulesEngine.SetLightsEvents.Count); Assert.AreEqual(null, rulesEngine.SetLightsEvents[1].LedPattern); }
public void GlobalPlayAudioAlertButOnMute_NoAudio() { var rulesEngine = new RulesEngineWrapper(); var audioPattern = new AudioPattern { Id = 2, Name = "Sally" }; rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.InitialFailedBuild, AudioPattern = audioPattern, AudioDuration = 60, }); rulesEngine.Settings.Mute = true; rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(0, rulesEngine.SetAudioEvents.Count); }
public void GlobalMuteOnBuildFailsWithWindowsAudioRule_NoAudio() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Settings.Mute = true; Rule rule = new Rule { TriggerType = TriggerType.InitialFailedBuild, WindowsAudioLocation = "SirenOfShame.Resources.Sad-Trombone.wav" }; rulesEngine.Rules.Add(rule); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(0, rulesEngine.PlayWindowsAudioEvents.Count); }
public void GlobalBuildDefTrayAlertConflictsWithLocalBuildDefModalAlert_ModalAlertOnly() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildFailed, AlertType = AlertType.TrayAlert, }); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildFailed, AlertType = AlertType.ModalDialog, BuildDefinitionId = RulesEngineWrapper.BUILD1_ID }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(1, rulesEngine.ModalDialogEvents.Count); Assert.AreEqual(0, rulesEngine.TrayNotificationEvents.Count); }
public void DuplicateBuildDefinitionIds_BuildDefinitionDisplayNamesGetQualified() { var rulesEngine = new RulesEngineWrapper(); var ciEntryPointSetting = rulesEngine.Settings.CiEntryPointSettings[0]; Assert.AreEqual("http://fake", ciEntryPointSetting.Url); var buildDefinitionSetting1 = ciEntryPointSetting.BuildDefinitionSettings[0]; var buildDefinitionSetting2 = ciEntryPointSetting.BuildDefinitionSettings[1]; buildDefinitionSetting2.Name = buildDefinitionSetting1.Name; rulesEngine.Settings.ClearDuplicateNameCache(); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(2, rulesEngine.RefreshStatusEvents.Count); var refreshStatusEvent = rulesEngine.RefreshStatusEvents.Last(); Assert.AreEqual(1, refreshStatusEvent.BuildStatusDtos.Count); var buildStatusDto = refreshStatusEvent.BuildStatusDtos[0]; Assert.AreEqual("Build Def 1 (fake)", buildStatusDto.BuildDefinitionDisplayName); }
public void BuildWorkingThenWorking_BuildInitiatedNewsItem() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(2, rulesEngine.NewNewsItemEvents.Count); var latestNewsItem = rulesEngine.NewNewsItemEvents[1]; Assert.AreEqual(RulesEngineWrapper.CURRENT_USER, latestNewsItem.Person.RawName); Assert.AreEqual("Successful build", latestNewsItem.Title); }
public void BuildSucceedsTwiceAfterFailWithGlobalInitialSuccessDialog_OnlyOneAlert() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.InitialSuccess, AlertType = AlertType.ModalDialog }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(1, rulesEngine.ModalDialogEvents.Count); Assert.AreEqual("Build is passing again for Build Def 1", rulesEngine.ModalDialogEvents[0].DialogText); }
public void BuildStartTimeChanged_RefreshStatus() { var rulesEngine = new RulesEngineWrapper(); var firstStartTime = new DateTime(2011, 1, 1, 1, 1, 1); var secondStartTime = new DateTime(2022, 2, 2, 2, 2, 2); rulesEngine.InvokeStatusChecked(new BuildStatus { BuildStatusEnum = BuildStatusEnum.Working, Name = RulesEngineWrapper.BUILD2_ID, RequestedBy = RulesEngineWrapper.CURRENT_USER, BuildDefinitionId = RulesEngineWrapper.BUILD2_ID, StartedTime = firstStartTime }); Assert.AreEqual(2, rulesEngine.RefreshStatusEvents.Count); rulesEngine.InvokeStatusChecked(new BuildStatus { BuildStatusEnum = BuildStatusEnum.Working, Name = RulesEngineWrapper.BUILD2_ID, RequestedBy = RulesEngineWrapper.CURRENT_USER, BuildDefinitionId = RulesEngineWrapper.BUILD2_ID, StartedTime = secondStartTime }); Assert.AreEqual(3, rulesEngine.RefreshStatusEvents.Count); Assert.AreEqual(BuildStatus.FormatAsDayMonthTime(secondStartTime), rulesEngine.RefreshStatusEvents.Last().BuildStatusDtos.First().StartTimeShort); }
public void InvokeStatusOnceForBuildAThenForBuildB_SecondRefreshStatusReturnsBuildAAndBuildB() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(new BuildStatus { BuildStatusEnum = BuildStatusEnum.Working, Name = RulesEngineWrapper.BUILD1_ID, RequestedBy = RulesEngineWrapper.CURRENT_USER, BuildDefinitionId = RulesEngineWrapper.BUILD1_ID, StartedTime = new DateTime(2011, 1, 1, 1, 1, 1) }); Assert.AreEqual(2, rulesEngine.RefreshStatusEvents.Count); rulesEngine.InvokeStatusChecked(new BuildStatus { BuildStatusEnum = BuildStatusEnum.Working, Name = RulesEngineWrapper.BUILD2_ID, RequestedBy = RulesEngineWrapper.CURRENT_USER, BuildDefinitionId = RulesEngineWrapper.BUILD2_ID, StartedTime = new DateTime(2011, 1, 1, 1, 1, 1) }); Assert.AreEqual(3, rulesEngine.RefreshStatusEvents.Count); var lastRefreshStatusEvent = rulesEngine.RefreshStatusEvents.Last(); Assert.AreEqual(2, lastRefreshStatusEvent.BuildStatusDtos.Count()); }
public void BuidFailsThenSucceedsWithGlobalSubsequentSuccessAlerts_NoAlert() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.SuccessfulBuild, AlertType = AlertType.TrayAlert }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(0, rulesEngine.TrayNotificationEvents.Count); }
public void Hudson_BuildUrlPassesThrough() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(new BuildStatus { BuildStatusEnum = BuildStatusEnum.InProgress, Name = "New Name!", RequestedBy = RulesEngineWrapper.CURRENT_USER, BuildDefinitionId = RulesEngineWrapper.BUILD1_ID, StartedTime = new DateTime(2010, 1, 1, 11, 33, 0), Url = "http://win7ci:8081/job/SvnTest/32/", BuildId = "32", }); Assert.AreEqual(2, rulesEngine.RefreshStatusEvents.Count); RefreshStatusEventArgs refreshStatusEventArgs = rulesEngine.RefreshStatusEvents[1]; Assert.AreEqual(1, refreshStatusEventArgs.BuildStatusDtos.Count()); Assert.AreEqual("http://win7ci:8081/job/SvnTest/32/", refreshStatusEventArgs.BuildStatusDtos.First().Url); Assert.AreEqual("32", refreshStatusEventArgs.BuildStatusDtos.First().BuildId); }
public void NewBuildWithEmptyRequestedBy_RequestByNotAdded() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.InitialFailedBuild, AlertType = AlertType.NoAlert, }); BuildDefinitionSetting build1Setting = rulesEngine.GetBuildDefinitionSetting(RulesEngineWrapper.BUILD1_ID); Assert.AreEqual(0, build1Setting.People.Count); rulesEngine.InvokeStatusChecked(new BuildStatus { BuildStatusEnum = BuildStatusEnum.Broken, Name = RulesEngineWrapper.BUILD1_ID, RequestedBy = "", BuildDefinitionId = RulesEngineWrapper.BUILD1_ID, StartedTime = new DateTime(2010, 1, 1) }); Assert.AreEqual(0, build1Setting.People.Count); }
public void BuildInitiated_BuildInitiatedNewsItem() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); Assert.AreEqual(1, rulesEngine.NewNewsItemEvents.Count); var newNewsItem = rulesEngine.NewNewsItemEvents[0]; Assert.AreEqual(RulesEngineWrapper.CURRENT_USER, newNewsItem.Person.RawName); Assert.AreEqual("'Fixing a typo'", newNewsItem.Title); }
public void OnStartup_NeverShowWorkingTrayNotifications() { var rulesEngine = new RulesEngineWrapper(); Rule rule = new Rule { TriggerType = TriggerType.SuccessfulBuild, AlertType = AlertType.TrayAlert }; rulesEngine.Rules.Add(rule); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(0, rulesEngine.TrayNotificationEvents.Count); }
public void InitialFailedBuildConflictsWithBuildFailedOrder2_InitialFailedBuildWins() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.InitialFailedBuild, AlertType = AlertType.ModalDialog, }); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildFailed, AlertType = AlertType.TrayAlert, }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken); Assert.AreEqual(1, rulesEngine.ModalDialogEvents.Count); Assert.AreEqual(0, rulesEngine.TrayNotificationEvents.Count); }
public void BuildInProgressTwiceWithGlobalBuildTriggeredRule_OnlyOneAlert() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.Rules.Add(new Rule { TriggerType = TriggerType.BuildTriggered, AlertType = AlertType.TrayAlert }); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); rulesEngine.InvokeStatusChecked(BuildStatusEnum.InProgress); Assert.AreEqual(1, rulesEngine.TrayNotificationEvents.Count); }
public void InitialStatesDoNotWrite() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); // do not write initial states var lines = rulesEngine.SosDb.ReadAll(RulesEngineWrapper.BUILD1_ID); Assert.AreEqual(0, lines.Count); }
public void InitialBuildStatusRequest_UsesServerTimeSinceLocalTimeIsNotAvaiable() { var rulesEngine = new RulesEngineWrapper(); Assert.AreEqual(1, rulesEngine.RefreshStatusEvents.Count); rulesEngine.InvokeStatusChecked(BuildStatusEnum.Working); Assert.AreEqual(2, rulesEngine.RefreshStatusEvents.Count); var refreshStatusEvent = rulesEngine.RefreshStatusEvents.Last(); var buildStatusDto = refreshStatusEvent.BuildStatusDtos.First(i => i.BuildDefinitionId == RulesEngineWrapper.BUILD1_ID); Assert.AreEqual(new DateTime(2010, 1, 1, 1, 1, 1), buildStatusDto.LocalStartTime); }
public void BuildNameChanges_BuildSettingsNameIsUpdated() { var rulesEngine = new RulesEngineWrapper(); rulesEngine.InvokeStatusChecked( new BuildStatus { BuildStatusEnum = BuildStatusEnum.InProgress, Name = "New Name!", RequestedBy = RulesEngineWrapper.CURRENT_USER, BuildDefinitionId = RulesEngineWrapper.BUILD1_ID, StartedTime = new DateTime(2010, 1, 1, 11, 33, 0) }); BuildDefinitionSetting buildDefinitionSetting = rulesEngine.Settings.CiEntryPointSettings.Single().BuildDefinitionSettings.Single(i => i.Id == RulesEngineWrapper.BUILD1_ID); Assert.AreEqual("New Name!", buildDefinitionSetting.Name); }