public void SerializeThenDeserialize()
        {
            SirenOfShameSettingsFake settings = new SirenOfShameSettingsFake();
            var person = settings.FindAddPerson("Bob");
            NewNewsItemEventArgs args = new NewNewsItemEventArgs
            {
                EventDate         = new DateTime(2010, 1, 2, 3, 4, 5, 6),
                Person            = person,
                Title             = "Hello world",
                NewsItemType      = NewsItemTypeEnum.BuildFailed,
                BuildDefinitionId = "Project 1",
                ReputationChange  = -1,
                BuildId           = "5",
            };
            var asCommaSeparated = args.AsCommaSeparated();
            var result           = NewNewsItemEventArgs.FromCommaSeparated(asCommaSeparated, settings);

            Assert.IsNotNull(result);
            Assert.AreEqual("Bob", result.Person.RawName);
            Assert.AreEqual("Hello world", result.Title);
            Assert.AreEqual(new DateTime(2010, 1, 2, 3, 4, 5, 6), result.EventDate);
            Assert.AreEqual(NewsItemTypeEnum.BuildFailed, result.NewsItemType);
            Assert.AreEqual(-1, result.ReputationChange);
            Assert.AreEqual("Project 1", result.BuildDefinitionId);
            Assert.AreEqual("5", result.BuildId);
        }
 public void GetPerson_PersonWithRawNameExists_PersonIsFound()
 {
     var settingsFake = new SirenOfShameSettingsFake();
     settingsFake.People.Add(new PersonSetting { RawName = "domain\richardsonl"});
     var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "domain\richardsonl");
     Assert.IsNotNull(actual);
 }
Example #3
0
        public void AsBuildStatusListViewItem_InProgressBuildRunningOverPreviousRunDuration_DurationCountsUpOvertime()
        {
            // current duration: 2 minute, 1 second
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = "MyBuild",
                LocalStartTime    = new DateTime(2010, 1, 1, 1, 1, 1),
                BuildStatusEnum   = BuildStatusEnum.InProgress
            };
            var now = new DateTime(2010, 1, 1, 1, 3, 2);

            // previous duration 1 minute
            var previousWorkingOrBrokenBuildStatus = new Dictionary <string, BuildStatus>
            {
                { "MyBuild", new BuildStatus
                  {
                      StartedTime  = new DateTime(2010, 1, 1, 1, 1, 0),
                      FinishedTime = new DateTime(2010, 1, 1, 1, 2, 0)
                  } }
            };
            var settings = new SirenOfShameSettingsFake();
            var result   = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);

            Assert.AreEqual("OT: 1:01", result.Duration);
        }
Example #4
0
        public void Write_TwoStatuses_TwoWrites()
        {
            string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "BuildDefinitionId.txt");

            File.Delete(expectedFileLocation);
            var         sosDb       = new SosDb();
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = "BuildDefinitionId",
                BuildStatusEnum   = BuildStatusEnum.Working,
                Comment           = "hi",
                FinishedTime      = new DateTime(2010, 1, 1, 1, 1, 1),
                StartedTime       = new DateTime(2010, 1, 1, 1, 1, 2),
                LocalStartTime    = new DateTime(2010, 1, 1, 1, 1, 3),
                RequestedBy       = "Lee",
                Name = "BuildName",
            };
            SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();

            sosDb.Write(buildStatus, fakeSettings, false);
            sosDb.Write(buildStatus, fakeSettings, false);
            Assert.IsTrue(File.Exists(expectedFileLocation));
            string[] linesOutput = File.ReadAllLines(expectedFileLocation);
            Assert.AreEqual(2, linesOutput.Length);
            Assert.AreEqual("633979044620000000,633979044610000000,1,Lee", linesOutput[0]);
            Assert.AreEqual("633979044620000000,633979044610000000,1,Lee", linesOutput[1]);
            File.Delete(expectedFileLocation);
        }
 public void SerializeThenDeserialize()
 {
     SirenOfShameSettingsFake settings = new SirenOfShameSettingsFake();
     var person = settings.FindAddPerson("Bob");
     NewNewsItemEventArgs args = new NewNewsItemEventArgs
     {
         EventDate = new DateTime(2010, 1, 2, 3, 4, 5, 6),
         Person = person,
         Title = "Hello world",
         NewsItemType = NewsItemTypeEnum.BuildFailed,
         BuildDefinitionId = "Project 1",
         ReputationChange = -1,
         BuildId = "5",
     };
     var asCommaSeparated = args.AsCommaSeparated();
     var result = NewNewsItemEventArgs.FromCommaSeparated(asCommaSeparated, settings);
     Assert.IsNotNull(result);
     Assert.AreEqual("Bob", result.Person.RawName);
     Assert.AreEqual("Hello world", result.Title);
     Assert.AreEqual(new DateTime(2010, 1, 2, 3, 4, 5, 6), result.EventDate);
     Assert.AreEqual(NewsItemTypeEnum.BuildFailed, result.NewsItemType);
     Assert.AreEqual(-1, result.ReputationChange);
     Assert.AreEqual("Project 1", result.BuildDefinitionId);
     Assert.AreEqual("5", result.BuildId);
 }
 public void GetPerson_NameContainsCommaButIsSearchedForWithoutComma_NameStillFound()
 {
     var settingsFake = new SirenOfShameSettingsFake();
     settingsFake.People.Add(new PersonSetting { RawName = "O'Boyle, Robert"});
     var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "O'Boyle  Robert");
     Assert.IsNotNull(actual);
 }
Example #7
0
        public void GetPerson_PersonWithRawNameDoesNotExist_NothingFound()
        {
            var settingsFake = new SirenOfShameSettingsFake();
            var actual       = NewNewsItemEventArgs.GetPerson(settingsFake, "domain\richardsonl");

            Assert.IsNull(actual);
        }
 public void Upgrade_SamePersonInMultipleSettings_NoDuplicates()
 {
     var settings = new SirenOfShameSettingsFake();
     settings.CiEntryPointSettings.Add(new CiEntryPointSetting
     {
         BuildDefinitionSettings = new List<BuildDefinitionSetting>
         {
             new BuildDefinitionSetting
             {
                 People = new List<string>
                 {
                     "Bob",
                 }
             },
             new BuildDefinitionSetting
             {
                 People = new List<string>
                 {
                     "Bob",
                 }
             }
         }
     });
     settings.DoUpgrade();
     Assert.AreEqual(1, settings.People.Count);
 }
Example #9
0
        public void GetPerson_NameContainsCommaButIsSearchedForWithoutComma_NameStillFound()
        {
            var settingsFake = new SirenOfShameSettingsFake();

            settingsFake.People.Add(new PersonSetting {
                RawName = "O'Boyle, Robert"
            });
            var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "O'Boyle  Robert");

            Assert.IsNotNull(actual);
        }
Example #10
0
        public void GetPerson_PersonWithRawNameExists_PersonIsFound()
        {
            var settingsFake = new SirenOfShameSettingsFake();

            settingsFake.People.Add(new PersonSetting {
                RawName = "domain\richardsonl"
            });
            var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "domain\richardsonl");

            Assert.IsNotNull(actual);
        }
Example #11
0
 public void ExportNewBuilds_InitialExportWithNoBuilds_Null()
 {
     SosDbFake sosDb = new SosDbFake();
     SirenOfShameSettings settings = new SirenOfShameSettingsFake
     {
         SosOnlineHighWaterMark = null,
         MyRawName = "CurrentUser"
     };
     sosDb.Write(new BuildStatus { BuildDefinitionId = "BD"}, settings, true);
     var result = sosDb.ExportNewBuilds(settings);
     Assert.IsNull(result);
 }
Example #12
0
 public void Upgrade_SubsequentBuildFailedRule_WindowsAudioSetToSadTrombone()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = null
                        };
     settings.Rules.Add(new Rule
     {
         TriggerType = TriggerType.SubsequentFailedBuild
     });
     new Upgrade2To3().Upgrade(settings);
     Assert.AreEqual(1, settings.Rules.Count);
     Assert.AreEqual("SirenOfShame.Resources.Audio-Boo-Hiss.wav", settings.Rules[0].WindowsAudioLocation);
 }
Example #13
0
 public void Upgrade_BuildTriggeredRule_WindowsAudioSetToPlunk()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = null
                        };
     settings.Rules.Add(new Rule
     {
         TriggerType = TriggerType.BuildTriggered
     });
     new Upgrade2To3().Upgrade(settings);
     Assert.AreEqual(1, settings.Rules.Count);
     Assert.AreEqual("SirenOfShame.Resources.Audio-Plunk.wav", settings.Rules[0].WindowsAudioLocation);
 }
 public void AsBuildStatusListViewItem_InProgressNoPreviousDuration_DurationCountsUp()
 {
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "MyBuild",
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 1),
         BuildStatusEnum = BuildStatusEnum.InProgress
     };
     var now = new DateTime(2010, 1, 1, 1, 2, 2);
     var previousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>();
     var settings = new SirenOfShameSettingsFake();
     var result = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);
     Assert.AreEqual("1:01", result.Duration);
 }
Example #15
0
        public void AsBuildStatusListViewItem_InProgressNoPreviousDuration_DurationCountsUp()
        {
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = "MyBuild",
                LocalStartTime    = new DateTime(2010, 1, 1, 1, 1, 1),
                BuildStatusEnum   = BuildStatusEnum.InProgress
            };
            var now = new DateTime(2010, 1, 1, 1, 2, 2);
            var previousWorkingOrBrokenBuildStatus = new Dictionary <string, BuildStatus>();
            var settings = new SirenOfShameSettingsFake();
            var result   = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);

            Assert.AreEqual("1:01", result.Duration);
        }
Example #16
0
        public void ExportNewBuilds_InitialExportWithNoBuilds_Null()
        {
            SosDbFake            sosDb    = new SosDbFake();
            SirenOfShameSettings settings = new SirenOfShameSettingsFake
            {
                SosOnlineHighWaterMark = null,
                MyRawName = "CurrentUser"
            };

            sosDb.Write(new BuildStatus {
                BuildDefinitionId = "BD"
            }, settings, true);
            var result = sosDb.ExportNewBuilds(settings);

            Assert.IsNull(result);
        }
 public void SerializeThenDeserialize_CommaSeparatedTitle()
 {
     SirenOfShameSettingsFake settings = new SirenOfShameSettingsFake();
     var person = settings.FindAddPerson("Bob");
     NewNewsItemEventArgs args = new NewNewsItemEventArgs
     {
         EventDate = new DateTime(2010, 1, 2, 3, 4, 5, 6),
         Person = person,
         NewsItemType = NewsItemTypeEnum.BuildFailed,
         Title = ",Hello, world,",
         BuildDefinitionId = "Project 1"
     };
     var asCommaSeparated = args.AsCommaSeparated();
     var result = NewNewsItemEventArgs.FromCommaSeparated(asCommaSeparated, settings);
     Assert.IsNotNull(result);
     Assert.AreEqual(",Hello, world,", result.Title);
 }
 public void ExportNewAchievements_InitialExportWithNoAchievements_Null()
 {
     var settings = new SirenOfShameSettingsFake
     {
         SosOnlineHighWaterMark = null,
         MyRawName = "CurrentUser",
         People = new List<PersonSetting>
         {
             new PersonSetting
             {
                 RawName = "CurrentUser",
                 Achievements = new List<AchievementSetting>()
             }
         }
     };
     Assert.IsNull(settings.ExportNewAchievements());
 }
 public void Upgrade_AllPeopleNotHidden()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = null
                        };
     settings.People.Add(new PersonSetting
                             {
                                 DisplayName = "Bob Thomas",
                                 FailedBuilds = 3,
                                 RawName = "domain\\bthomas",
                                 TotalBuilds = 100
                             });
     new Upgrade1To2().Upgrade(settings);
     Assert.AreEqual(1, settings.People.Count);
     Assert.AreEqual(false, settings.People[0].Hidden);
 }
Example #20
0
        public RulesEngineWrapper()
        {
            TrayNotificationEvents = new List <TrayNotifyEventArgs>();
            SetTrayIconEvents      = new List <SetTrayIconEventArgs>();
            RefreshStatusEvents    = new List <RefreshStatusEventArgs>();
            PlayWindowsAudioEvents = new List <PlayWindowsAudioEventArgs>();
            StatusBarUpdateEvents  = new List <UpdateStatusBarEventArgs>();
            ModalDialogEvents      = new List <ModalDialogEventArgs>();
            SetAudioEvents         = new List <SetAudioEventArgs>();
            SetLightsEvents        = new List <SetLightsEventArgs>();
            NewAlertEvents         = new List <NewAlertEventArgs>();
            NewAchievementEvents   = new List <NewAchievementEventArgs>();
            NewNewsItemEvents      = new List <NewNewsItemEventArgs>();
            NewUserEvents          = new List <NewUserEventArgs>();

            Settings            = new SirenOfShameSettingsFake();
            CiEntryPointSetting = new CiEntryPointSettingFake(Settings);
            Settings.CiEntryPointSettings.Add(CiEntryPointSetting);
            Settings.CiEntryPointSettings.First().BuildDefinitionSettings.Add(new BuildDefinitionSetting {
                Active = true, AffectsTrayIcon = true, Id = BUILD1_ID, Name = "Build Def 1"
            });
            Settings.CiEntryPointSettings.First().BuildDefinitionSettings.Add(new BuildDefinitionSetting {
                Active = true, AffectsTrayIcon = true, Id = BUILD2_ID, Name = "Build Def 2"
            });

            _rulesEngine = new FakeRulesEngine(Settings)
            {
                SosDb = _sosDbFake
            };

            _rulesEngine.TrayNotify       += (sender, arg) => TrayNotificationEvents.Add(arg);
            _rulesEngine.SetTrayIcon      += (sender, arg) => SetTrayIconEvents.Add(arg);
            _rulesEngine.RefreshStatus    += (sender, arg) => RefreshStatusEvents.Add(arg);
            _rulesEngine.PlayWindowsAudio += (sender, arg) => PlayWindowsAudioEvents.Add(arg);
            _rulesEngine.UpdateStatusBar  += (sender, arg) => StatusBarUpdateEvents.Add(arg);
            _rulesEngine.ModalDialog      += (sender, arg) => ModalDialogEvents.Add(arg);
            _rulesEngine.SetAudio         += (sender, arg) => SetAudioEvents.Add(arg);
            _rulesEngine.SetLights        += (sender, arg) => SetLightsEvents.Add(arg);
            _rulesEngine.NewAlert         += (sender, arg) => NewAlertEvents.Add(arg);
            _rulesEngine.NewAchievement   += (sender, arg) => NewAchievementEvents.Add(arg);
            _rulesEngine.NewNewsItem      += (sender, arg) => NewNewsItemEvents.Add(arg);
            _rulesEngine.NewUser          += (sender, arg) => NewUserEvents.Add(arg);
            _rulesEngine.StatsChanged     += (sender, arg) => StatsChangedEvents.Add(arg);

            _rulesEngine.Start(initialStart: true);
        }
Example #21
0
 public void Upgrade_BuildFailedRule_WindowsAudioSetToSadTrombone()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = null
                        };
     settings.Rules.Add(new Rule
     {
         TriggerType = TriggerType.BuildFailed
     });
     settings.Rules.Add(new Rule
     {
         TriggerType = TriggerType.InitialFailedBuild
     });
     new Upgrade2To3().Upgrade(settings);
     Assert.AreEqual(2, settings.Rules.Count);
     Assert.IsTrue(settings.Rules.All(i => i.WindowsAudioLocation == "SirenOfShame.Resources.Audio-Sad-Trombone.wav"));
 }
        public void TryToGetAndSendNewSosOnlineAlerts_HaveNeverCheckedForAlertsButSettingsSayNeverDownload_DoNotSendAlertToUi()
        {
            var sosOnlineService = new SosOnlineServiceFake();
            var settings = new SirenOfShameSettingsFake();
            settings.UpdateLocation = UpdateLocation.Never;
            settings.LastCheckedForAlert = null;
            NewAlertEventArgs newAlertEventArgs = null;
            sosOnlineService.TryToGetAndSendNewSosOnlineAlerts(settings, new DateTime(2010, 1, 1), alert =>
            {
                newAlertEventArgs = alert;
            });

            sosOnlineService.FakeWebClient.InvokeDownloadStringCompleted(@"56
            http://www.google.com
            Hello World
            633979872000000000");
            Assert.IsNull(newAlertEventArgs);
        }
        public void SerializeThenDeserialize_CommaSeparatedTitle()
        {
            SirenOfShameSettingsFake settings = new SirenOfShameSettingsFake();
            var person = settings.FindAddPerson("Bob");
            NewNewsItemEventArgs args = new NewNewsItemEventArgs
            {
                EventDate         = new DateTime(2010, 1, 2, 3, 4, 5, 6),
                Person            = person,
                NewsItemType      = NewsItemTypeEnum.BuildFailed,
                Title             = ",Hello, world,",
                BuildDefinitionId = "Project 1"
            };
            var asCommaSeparated = args.AsCommaSeparated();
            var result           = NewNewsItemEventArgs.FromCommaSeparated(asCommaSeparated, settings);

            Assert.IsNotNull(result);
            Assert.AreEqual(",Hello, world,", result.Title);
        }
Example #24
0
        public void Write_InvalidCharacters_Removed()
        {
            const string uglyBuildDefinition  = "\"M\"\\(a)/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";
            string       expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "M(a)ry had a little lamb.txt");

            File.Delete(expectedFileLocation);
            var         sosDb       = new SosDb();
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = uglyBuildDefinition,
                BuildStatusEnum   = BuildStatusEnum.Working,
                Name = "BuildName",
            };
            SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();

            sosDb.Write(buildStatus, fakeSettings, false);
            Assert.IsTrue(File.Exists(expectedFileLocation));
            File.Delete(expectedFileLocation);
        }
 public void ExportNewAchievements_InitialExportWithOneNewAchievementByCurrentUser_Exports()
 {
     var settings = new SirenOfShameSettingsFake
     {
         SosOnlineHighWaterMark = null,
         MyRawName = "CurrentUser",
         People = new List<PersonSetting>
         {
             new PersonSetting
             {
                 RawName = "CurrentUser",
                 Achievements = new List<AchievementSetting>
                 {
                     new AchievementSetting { AchievementId = 1, DateAchieved = new DateTime(2010, 1, 1, 1, 1, 2)}
                 }
             }
         }
     };
     Assert.AreEqual("1,633979044620000000", settings.ExportNewAchievements());
 }
        public void TryToGetAndSendNewSosOnlineAlerts_LastCheckedForNewAlertsOneSecondAgo_DoNotSendAlertToUi()
        {
            var sosOnlineService = new SosOnlineServiceFake();
            var settings = new SirenOfShameSettingsFake();
            var now = new DateTime(2010, 2, 2, 2, 2, 1);
            settings.LastCheckedForAlert = new DateTime(2010, 2, 2, 2, 2, 2);

            NewAlertEventArgs newAlertEventArgs = null;
            sosOnlineService.TryToGetAndSendNewSosOnlineAlerts(settings, now, alert =>
            {
                newAlertEventArgs = alert;
            });

            sosOnlineService.FakeWebClient.InvokeDownloadStringCompleted(@"56
            http://www.google.com
            Hello World
            633979872000000000");

            Assert.IsNull(newAlertEventArgs);
        }
        public RulesEngineWrapper()
        {
            TrayNotificationEvents = new List<TrayNotifyEventArgs>();
            SetTrayIconEvents = new List<SetTrayIconEventArgs>();
            RefreshStatusEvents = new List<RefreshStatusEventArgs>();
            PlayWindowsAudioEvents = new List<PlayWindowsAudioEventArgs>();
            StatusBarUpdateEvents = new List<UpdateStatusBarEventArgs>();
            ModalDialogEvents = new List<ModalDialogEventArgs>();
            SetAudioEvents = new List<SetAudioEventArgs>();
            SetLightsEvents = new List<SetLightsEventArgs>();
            NewAlertEvents = new List<NewAlertEventArgs>();
            NewAchievementEvents = new List<NewAchievementEventArgs>();
            NewNewsItemEvents = new List<NewNewsItemEventArgs>();
            NewUserEvents = new List<NewUserEventArgs>();

            Settings = new SirenOfShameSettingsFake();
            CiEntryPointSetting = new CiEntryPointSettingFake(Settings);
            Settings.CiEntryPointSettings.Add(CiEntryPointSetting);
            Settings.CiEntryPointSettings.First().BuildDefinitionSettings.Add(new BuildDefinitionSetting { Active = true, AffectsTrayIcon = true, Id = BUILD1_ID, Name = "Build Def 1" });
            Settings.CiEntryPointSettings.First().BuildDefinitionSettings.Add(new BuildDefinitionSetting { Active = true, AffectsTrayIcon = true, Id = BUILD2_ID, Name = "Build Def 2" });

            _rulesEngine = new FakeRulesEngine(Settings)
            {
                SosDb = _sosDbFake
            };

            _rulesEngine.TrayNotify += (sender, arg) => TrayNotificationEvents.Add(arg);
            _rulesEngine.SetTrayIcon += (sender, arg) => SetTrayIconEvents.Add(arg);
            _rulesEngine.RefreshStatus += (sender, arg) => RefreshStatusEvents.Add(arg);
            _rulesEngine.PlayWindowsAudio += (sender, arg) => PlayWindowsAudioEvents.Add(arg);
            _rulesEngine.UpdateStatusBar += (sender, arg) => StatusBarUpdateEvents.Add(arg);
            _rulesEngine.ModalDialog += (sender, arg) => ModalDialogEvents.Add(arg);
            _rulesEngine.SetAudio += (sender, arg) => SetAudioEvents.Add(arg);
            _rulesEngine.SetLights += (sender, arg) => SetLightsEvents.Add(arg);
            _rulesEngine.NewAlert += (sender, arg) => NewAlertEvents.Add(arg);
            _rulesEngine.NewAchievement += (sender, arg) => NewAchievementEvents.Add(arg);
            _rulesEngine.NewNewsItem += (sender, arg) => NewNewsItemEvents.Add(arg);
            _rulesEngine.NewUser += (sender, arg) => NewUserEvents.Add(arg);

            _rulesEngine.Start(initialStart: true);
        }
        public void TryToGetAndSendNewSosOnlineAlerts_HaveNeverCheckedForAlerts_SendAlertToUi()
        {
            var sosOnlineService = new SosOnlineServiceFake();
            var settings = new SirenOfShameSettingsFake();
            settings.LastCheckedForAlert = null;
            NewAlertEventArgs newAlertEventArgs = null;
            sosOnlineService.TryToGetAndSendNewSosOnlineAlerts(settings, new DateTime(2010, 1, 1), alert =>
            {
                newAlertEventArgs = alert;
            });

            sosOnlineService.FakeWebClient.InvokeDownloadStringCompleted(@"56
            http://www.google.com
            Hello World
            633979872000000000");

            Assert.IsNotNull(newAlertEventArgs, "Expected WebClient.DownloadStringAsync to be called, but it never was");
            Assert.AreEqual("Hello World", newAlertEventArgs.Message);
            Assert.AreEqual("http://www.google.com", newAlertEventArgs.Url);
            Assert.AreEqual(new DateTime(2010, 1, 2), newAlertEventArgs.AlertDate);
        }
 public void AsBuildStatusListViewItem_InProgressPreviousRunOneMinuteBuildJustStarted_DurationCountsDown()
 {
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "MyBuild",
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 1),
         BuildStatusEnum = BuildStatusEnum.InProgress
     };
     var now = new DateTime(2010, 1, 1, 1, 1, 1);
     var previousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>
     {
         { "MyBuild", new BuildStatus
         {
             StartedTime = new DateTime(2010, 1, 1, 1, 1, 0),
             FinishedTime = new DateTime(2010, 1, 1, 1, 2, 0)
         } }
     };
     var settings = new SirenOfShameSettingsFake();
     var result = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);
     Assert.AreEqual("1:00", result.Duration); // would have been 0:00 if counting up
 }
Example #30
0
 public void ExportNewBuilds_InitialExportWithOneSuccessfulBuildBySomeoneElse_Null()
 {
     SosDbFake sosDb = new SosDbFake();
     SirenOfShameSettings settings = new SirenOfShameSettingsFake
     {
         SosOnlineHighWaterMark = null,
         MyRawName = "CurrentUser"
     };
     sosDb.Write(new BuildStatus
     {
         StartedTime = new DateTime(2010, 1, 1, 1, 1, 1),
         FinishedTime = new DateTime(2010, 1, 1, 1, 1, 2),
         BuildStatusEnum = BuildStatusEnum.Working,
         BuildDefinitionId = "BuildDefinitionId",
         BuildId = "BuildId",
         Name = "Name",
         RequestedBy = "SomeoneElse",
         Comment = "Comment",
     }, settings, true);
     var result = sosDb.ExportNewBuilds(settings);
     Assert.AreEqual(null, result);
 }
 public void Upgrade_ThreePeopleTwoAvatarImages_LastPersonsAvatarIdLoopsBackToZero()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = null,
                            People = new List<PersonSetting>
                            {
                                new PersonSetting { RawName = "1"},
                                new PersonSetting { RawName = "2"},
                                new PersonSetting { RawName = "3"},
                            }
                        };
     settings.Rules.Add(new Rule
     {
         TriggerType = TriggerType.BuildTriggered
     });
     new Upgrade5To6(2).Upgrade(settings);
     Assert.AreEqual(3, settings.People.Count);
     Assert.AreEqual(0, settings.People[0].AvatarId);
     Assert.AreEqual(1, settings.People[1].AvatarId);
     Assert.AreEqual(0, settings.People[2].AvatarId);
 }
Example #32
0
        public void AsBuildStatusListViewItem_InProgressPreviousRunOneMinuteBuildJustStarted_DurationCountsDown()
        {
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = "MyBuild",
                LocalStartTime    = new DateTime(2010, 1, 1, 1, 1, 1),
                BuildStatusEnum   = BuildStatusEnum.InProgress
            };
            var now = new DateTime(2010, 1, 1, 1, 1, 1);
            var previousWorkingOrBrokenBuildStatus = new Dictionary <string, BuildStatus>
            {
                { "MyBuild", new BuildStatus
                  {
                      StartedTime  = new DateTime(2010, 1, 1, 1, 1, 0),
                      FinishedTime = new DateTime(2010, 1, 1, 1, 2, 0)
                  } }
            };
            var settings = new SirenOfShameSettingsFake();
            var result   = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);

            Assert.AreEqual("1:00", result.Duration); // would have been 0:00 if counting up
        }
Example #33
0
        public void ExportNewBuilds_InitialExportWithOneSuccessfulBuildByCurrentUser_Exports()
        {
            SosDbFake            sosDb    = new SosDbFake();
            SirenOfShameSettings settings = new SirenOfShameSettingsFake
            {
                SosOnlineHighWaterMark = null,
                MyRawName            = "CurrentUser",
                CiEntryPointSettings = new List <CiEntryPointSetting>
                {
                    new CiEntryPointSetting
                    {
                        BuildDefinitionSettings = new List <BuildDefinitionSetting>
                        {
                            new BuildDefinitionSetting
                            {
                                Id     = "BuildDefinitionId",
                                Active = true
                            }
                        }
                    }
                }
            };

            sosDb.Write(new BuildStatus
            {
                StartedTime       = new DateTime(2010, 1, 1, 1, 1, 1),
                FinishedTime      = new DateTime(2010, 1, 1, 1, 1, 2),
                BuildStatusEnum   = BuildStatusEnum.Working,
                BuildDefinitionId = "BuildDefinitionId",
                BuildId           = "BuildId",
                Name        = "Name",
                RequestedBy = "CurrentUser",
                Comment     = "Comment",
            }, settings, false);
            var result = sosDb.ExportNewBuilds(settings);

            Assert.AreEqual("633979044610000000,633979044620000000,1", result);
        }
Example #34
0
        public void ExportNewBuilds_SecondExportGetsNewerExports()
        {
            SosDbFake            sosDb    = new SosDbFake();
            SirenOfShameSettings settings = new SirenOfShameSettingsFake
            {
                SosOnlineHighWaterMark = 633979044610000000,
                MyRawName            = "CurrentUser",
                CiEntryPointSettings = new List <CiEntryPointSetting>
                {
                    new CiEntryPointSetting
                    {
                        BuildDefinitionSettings = new List <BuildDefinitionSetting>
                        {
                            new BuildDefinitionSetting
                            {
                                Id     = "BuildDefinitionId",
                                Active = true
                            }
                        }
                    }
                }
            };

            sosDb.Write(new BuildStatus
            {
                StartedTime       = new DateTime(2010, 1, 1, 1, 1, 2),
                FinishedTime      = new DateTime(2010, 1, 1, 1, 1, 3),
                BuildStatusEnum   = BuildStatusEnum.Broken,
                BuildDefinitionId = "BuildDefinitionId",
                BuildId           = "BuildId",
                Name        = "Name",
                RequestedBy = "CurrentUser",
                Comment     = "Comment",
            }, settings);
            var result = sosDb.ExportNewBuilds(settings);

            Assert.AreEqual("633979044620000000,633979044630000000,0", result);
        }
 public void Upgrade_EmptyPeople_Removed()
 {
     var settings = new SirenOfShameSettingsFake();
     settings.CiEntryPointSettings.Add(new CiEntryPointSetting
     {
         BuildDefinitionSettings = new List<BuildDefinitionSetting>
         {
             new BuildDefinitionSetting
             {
                 People = new List<string>
                 {
                     "Bob",
                     ""
                 }
             }
         }
     });
     settings.DoUpgrade();
     var allPeople = settings.CiEntryPointSettings
         .SelectMany(i => i.BuildDefinitionSettings)
         .SelectMany(i => i.People);
     Assert.IsFalse(allPeople.Any(p => string.IsNullOrEmpty(p)));
 }
        public void AsBuildStatusListViewItem_InProgressBuildRunningOverPreviousRunDuration_DurationCountsUpOvertime()
        {
            // current duration: 2 minute, 1 second
            BuildStatus buildStatus = new BuildStatus
            {
                BuildDefinitionId = "MyBuild",
                LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 1),
                BuildStatusEnum = BuildStatusEnum.InProgress
            };
            var now = new DateTime(2010, 1, 1, 1, 3, 2);

            // previous duration 1 minute
            var previousWorkingOrBrokenBuildStatus = new Dictionary<string, BuildStatus>
            {
                { "MyBuild", new BuildStatus
                {
                    StartedTime = new DateTime(2010, 1, 1, 1, 1, 0),
                    FinishedTime = new DateTime(2010, 1, 1, 1, 2, 0)
                } }
            };
            var settings = new SirenOfShameSettingsFake();
            var result = buildStatus.AsBuildStatusDto(now, previousWorkingOrBrokenBuildStatus, settings);
            Assert.AreEqual("OT: 1:01", result.Duration);
        }
 public void Upgrade_PeopleInSettings_AddedToPeopleInBase()
 {
     var settings = new SirenOfShameSettingsFake();
     settings.CiEntryPointSettings.Add(new CiEntryPointSetting
     {
         BuildDefinitionSettings = new List<BuildDefinitionSetting>
         {
             new BuildDefinitionSetting
             {
                 People = new List<string>
                 {
                     "Bob",
                 }
             }
         }
     });
     settings.DoUpgrade();
     Assert.AreEqual(1, settings.People.Count);
     PersonSetting personSetting = settings.People.First();
     Assert.AreEqual("Bob", personSetting.RawName);
     Assert.AreEqual("Bob", personSetting.DisplayName);
     Assert.AreEqual(0, personSetting.FailedBuilds);
     Assert.AreEqual(0, personSetting.TotalBuilds);
 }
Example #38
0
 public void ExportNewBuilds_InitialExportWithOneSuccessfulBuildByCurrentUser_Exports()
 {
     SosDbFake sosDb = new SosDbFake();
     SirenOfShameSettings settings = new SirenOfShameSettingsFake
     {
         SosOnlineHighWaterMark = null,
         MyRawName = "CurrentUser",
         CiEntryPointSettings = new List<CiEntryPointSetting>
         {
             new CiEntryPointSetting
             {
                 BuildDefinitionSettings = new List<BuildDefinitionSetting>
                 {
                     new BuildDefinitionSetting
                     {
                         Id = "BuildDefinitionId",
                         Active = true
                     }
                 }
             }
         }
     };
     sosDb.Write(new BuildStatus
     {
         StartedTime = new DateTime(2010, 1, 1, 1, 1, 1),
         FinishedTime = new DateTime(2010, 1, 1, 1, 1, 2),
         BuildStatusEnum = BuildStatusEnum.Working,
         BuildDefinitionId = "BuildDefinitionId",
         BuildId = "BuildId",
         Name = "Name",
         RequestedBy = "CurrentUser",
         Comment = "Comment",
     }, settings, false);
     var result = sosDb.ExportNewBuilds(settings);
     Assert.AreEqual("633979044610000000,633979044620000000,1", result);
 }
Example #39
0
        public void ExportNewBuilds_InitialExportWithOneSuccessfulBuildBySomeoneElse_Null()
        {
            SosDbFake            sosDb    = new SosDbFake();
            SirenOfShameSettings settings = new SirenOfShameSettingsFake
            {
                SosOnlineHighWaterMark = null,
                MyRawName = "CurrentUser"
            };

            sosDb.Write(new BuildStatus
            {
                StartedTime       = new DateTime(2010, 1, 1, 1, 1, 1),
                FinishedTime      = new DateTime(2010, 1, 1, 1, 1, 2),
                BuildStatusEnum   = BuildStatusEnum.Working,
                BuildDefinitionId = "BuildDefinitionId",
                BuildId           = "BuildId",
                Name        = "Name",
                RequestedBy = "SomeoneElse",
                Comment     = "Comment",
            }, settings, true);
            var result = sosDb.ExportNewBuilds(settings);

            Assert.AreEqual(null, result);
        }
Example #40
0
        public void ExportNewBuilds_SecondExportIgnoresOlderExports()
        {
            SosDbFake            sosDb    = new SosDbFake();
            SirenOfShameSettings settings = new SirenOfShameSettingsFake
            {
                SosOnlineHighWaterMark = 633979044610000000,
                MyRawName = "CurrentUser"
            };

            sosDb.Write(new BuildStatus
            {
                StartedTime       = new DateTime(2010, 1, 1, 1, 1, 1),
                FinishedTime      = new DateTime(2010, 1, 1, 1, 1, 2),
                BuildStatusEnum   = BuildStatusEnum.Working,
                BuildDefinitionId = "BuildDefinitionId",
                BuildId           = "BuildId",
                Name        = "Name",
                RequestedBy = "CurrentUser",
                Comment     = "Comment",
            }, settings, true);
            var result = sosDb.ExportNewBuilds(settings);

            Assert.AreEqual(null, result);
        }
 public void Upgrade_FutureVersion_NotDowngraded()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = int.MaxValue
                        };
     settings.DoUpgrade();
     Assert.AreEqual(int.MaxValue, settings.Version);
 }
Example #42
0
 public void Write_Writes()
 {
     string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "BuildDefinitionId.txt");
     File.Delete(expectedFileLocation);
     var sosDb = new SosDb();
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "BuildDefinitionId",
         BuildStatusEnum = BuildStatusEnum.Working,
         Comment = "hi",
         FinishedTime = new DateTime(2010, 1, 1, 1, 1, 1),
         StartedTime = new DateTime(2010, 1, 1, 1, 1, 2),
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 3),
         RequestedBy = "Lee",
         Name = "BuildName",
     };
     SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();
     sosDb.Write(buildStatus, fakeSettings);
     Assert.IsTrue(File.Exists(expectedFileLocation));
     string[] linesOutput = File.ReadAllLines(expectedFileLocation);
     Assert.AreEqual(1, linesOutput.Length);
     Assert.AreEqual("633979044620000000,633979044610000000,1,Lee", linesOutput[0]);
     File.Delete(expectedFileLocation);
 }
 public void ExportNewBuilds_InitialExportWithOneSuccessfulBuildBySomeoneElse_Null()
 {
     var settings = new SirenOfShameSettingsFake
     {
         SosOnlineHighWaterMark = null,
         MyRawName = "CurrentUser",
         People = new List<PersonSetting>
         {
             new PersonSetting
             {
                 RawName = "SomeoneElse",
                 Achievements = new List<AchievementSetting>
                 {
                     new AchievementSetting { AchievementId = 1, DateAchieved = new DateTime(2010, 1, 1, 1, 1, 2)}
                 }
             }
         }
     };
     Assert.AreEqual(null, settings.ExportNewAchievements());
 }
 public void GetPerson_PersonWithRawNameDoesNotExist_NothingFound()
 {
     var settingsFake = new SirenOfShameSettingsFake();
     var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "domain\richardsonl");
     Assert.IsNull(actual);
 }
 public void Upgrade_NullVersion_UpgradedToMostRecent()
 {
     var settings = new SirenOfShameSettingsFake
                        {
                            Version = null
                        };
     settings.DoUpgrade();
     Assert.AreEqual(7, settings.Version);
 }
Example #46
0
 public void Write_InvalidCharacters_Removed()
 {
     const string uglyBuildDefinition = "\"M\"\\(a)/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";
     string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "M(a)ry had a little lamb.txt");
     File.Delete(expectedFileLocation);
     var sosDb = new SosDb();
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = uglyBuildDefinition,
         BuildStatusEnum = BuildStatusEnum.Working,
         Name = "BuildName",
     };
     SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();
     sosDb.Write(buildStatus, fakeSettings);
     Assert.IsTrue(File.Exists(expectedFileLocation));
     File.Delete(expectedFileLocation);
 }