public void AllBuildsFromThreeDefinitionsShouldResultInMessageTellingAboutDefinition()
        {
            // arrange
            var build1 = CreateBuildNode(_ciDefinition, _stageBranch, "1", BuildStatus.Failed);
            var build2 = CreateBuildNode(_ciDefinition, _masterBranch, "2", BuildStatus.Failed);
            var build3 = CreateBuildNode(_nightlyDefinition, _stageBranch, "3", BuildStatus.Failed);
            var build4 = CreateBuildNode(_cloudDefinition, _featureBranch, "4", BuildStatus.Failed);
            var delta  = new BuildTreeBuildsDelta();

            delta.FailedBuilds.Add(build1);
            delta.FailedBuilds.Add(build2);
            delta.FailedBuilds.Add(build3);
            delta.FailedBuilds.Add(build4);

            // act
            var messages = new NotificationFactory(_allowAllConfiguration, _userIdentityList).ProduceNotifications(delta);

            // assert
            var message = messages.First();

            Assert.Equal(message.ContentTextId, DefinitionNotification.ThreeDefinitionsChangedTextId);
            Assert.True(message.DisplayContent.Contains(_ciDefinition.Name, StringComparison.Ordinal));
            Assert.True(message.DisplayContent.Contains(_nightlyDefinition.Name, StringComparison.Ordinal));
            Assert.True(message.DisplayContent.Contains(_cloudDefinition.Name, StringComparison.Ordinal));
        }
        public void SingleBuildFailingShouldResultInMessageTellingAboutBuild()
        {
            // arrange
            var build = CreateBuildNode(_ciDefinition, _stageBranch, "1", BuildStatus.Failed);
            var delta = new BuildTreeBuildsDelta();

            delta.FailedBuilds.Add(build);

            // act
            var messages = new NotificationFactory(_allowAllConfiguration, _userIdentityList).ProduceNotifications(delta);

            // assert
            var message = messages.First();

            Assert.Equal(message.ContentTextId, BuildNotification.BuildChangedTextId);
            Assert.True(message.DisplayContent.Contains(_ciDefinition.Name, StringComparison.Ordinal));
            Assert.True(message.DisplayContent.Contains(_stageBranch.FullName, StringComparison.Ordinal));
        }
        public void PartiallySucceededBuildWithSettingOnTreatAsFailedShouldResultInFailMessage()
        {
            // arrange
            var build = CreateBuildNode(_ciDefinition, _stageBranch, "1", BuildStatus.PartiallySucceeded);
            var delta = new BuildTreeBuildsDelta();

            delta.FailedBuilds.Add(build);

            // act
            var messages = new NotificationFactory(_treatPartialsAsFailedConfiguration, _userIdentityList).ProduceNotifications(delta);

            // assert
            var message = messages.First();

            Assert.Equal(message.ContentTextId, BuildNotification.BuildChangedTextId);
            Assert.True(message.DisplayContent.Contains(_ciDefinition.Name, StringComparison.Ordinal));
            Assert.True(message.DisplayContent.Contains(_stageBranch.FullName, StringComparison.Ordinal));
            Assert.Equal(BuildStatus.Failed, message.Status);
        }
        public void BuildsFromFourDefinitionsAndFourBranchesShouldResultInMessageTellingAboutBuilds()
        {
            // arrange
            var build1 = CreateBuildNode(_ciDefinition, _stageBranch, "1", BuildStatus.Failed);
            var build2 = CreateBuildNode(_mobileDefinition, _masterBranch, "2", BuildStatus.Failed);
            var build3 = CreateBuildNode(_nightlyDefinition, _bugBranch, "3", BuildStatus.Failed);
            var build4 = CreateBuildNode(_cloudDefinition, _featureBranch, "4", BuildStatus.Failed);
            var delta  = new BuildTreeBuildsDelta();

            delta.FailedBuilds.Add(build1);
            delta.FailedBuilds.Add(build2);
            delta.FailedBuilds.Add(build3);
            delta.FailedBuilds.Add(build4);

            // act
            var messages = new NotificationFactory(_allowAllConfiguration, _userIdentityList).ProduceNotifications(delta);

            // assert
            var message = messages.First();

            Assert.Equal(message.ContentTextId, BuildNotification.BuildsChangedTextId);
        }
        public void BranchNamesShouldGetTruncated()
        {
            // arrange
            var build1 = CreateBuildNode(_ciDefinition, _longNameFeatureABranch, "1", BuildStatus.Failed);
            var build2 = CreateBuildNode(_mobileDefinition, _longNameFeatureBBranch, "2", BuildStatus.Failed);
            var build3 = CreateBuildNode(_nightlyDefinition, _longNameFeatureCBranch, "3", BuildStatus.Failed);
            var build4 = CreateBuildNode(_cloudDefinition, _longNameFeatureABranch, "4", BuildStatus.Failed);
            var delta  = new BuildTreeBuildsDelta();

            delta.FailedBuilds.Add(build1);
            delta.FailedBuilds.Add(build2);
            delta.FailedBuilds.Add(build3);
            delta.FailedBuilds.Add(build4);

            // act
            var messages = new NotificationFactory(_allowAllConfiguration, _userIdentityList).ProduceNotifications(delta);

            // assert
            var message = messages.First();

            Assert.Equal(message.ContentTextId, BranchNotification.ThreeBranchesChangedTextId);
            Assert.False(message.DisplayContent.Contains(LongFeatureNameBase, StringComparison.Ordinal));
        }