コード例 #1
0
        public void HandleBuildCompletion(BuildCompletionEvent buildEvent)
        {
            var teamProjectMapping = FindTeamProjectMapping(buildEvent.TeamProject);

            if (teamProjectMapping == null)
            {
                return;
            }

            var notification = (buildEvent.CompletionStatus == "Successfully Completed")
                                   ? Notification.BuildCompletionSuccess
                                   : Notification.BuildCompletionFailure;

            if (!IsNotificationSubscribedTo(teamProjectMapping, notification))
            {
                return;
            }

            if (notification == Notification.BuildCompletionSuccess)
            {
                _hipChatNotifier.SendBuildSuccessNotification(buildEvent, teamProjectMapping.HipChatRoomId);
            }
            else
            {
                _hipChatNotifier.SendBuildFailedNotification(buildEvent, teamProjectMapping.HipChatRoomId);
            }
        }
コード例 #2
0
 public void SendBuildSuccessNotification(BuildCompletionEvent buildEvent, int roomId)
 {
     var message = string.Format("{0} build <a href=\"{1}\">{2}</a> {3} (requested by {4})",
         buildEvent.TeamProject, buildEvent.Url, buildEvent.Id, buildEvent.CompletionStatus,
         buildEvent.GetRequestedByName());
     _hipChatClient.RoomId = roomId;
     _hipChatClient.SendMessage(message, HipChatClient.BackgroundColor.green);
 }
コード例 #3
0
        public void GetRequestedByName_ShouldReturnUnformattedName_WhenNonStandardDomainName()
        {
            var buildEvent = new BuildCompletionEvent { RequestedBy = @"DOMAIN\uname1" };

            var name = buildEvent.GetRequestedByName();

            Assert.Equal(@"DOMAIN\uname1", name);
        }
コード例 #4
0
        public void HandleBuildCompletion_ShouldNotSendBuildSuccess_WhenBuildBroken()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent { TeamProject = "TestProject" };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.DidNotReceiveWithAnyArgs().SendBuildSuccessNotification(null, 0);
        }
コード例 #5
0
        public void HandleBuildCompletion_ShouldNotSendBuildFailed_WhenNotificationNotSubscribed()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent { TeamProject = "ProjectWithOnlyCheckin" };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.DidNotReceiveWithAnyArgs().SendBuildFailedNotification(null, 0);
        }
コード例 #6
0
        public void HandleBuildCompletion_ShouldNotSendBuildSuccess_WhenBuildSuccessfulAndMappingNotDefined()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent
                                 {
                                     CompletionStatus = "Successfully Completed",
                                     TeamProject = "ProjectWithNoMapping"
                                 };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.DidNotReceiveWithAnyArgs().SendBuildSuccessNotification(null, 0);
        }
コード例 #7
0
        public void HandleBuildCompletion_ShouldSendBuildSuccessToCorrectRoom_WhenBuildSuccessful()
        {
            var notifier = Substitute.For<IHipChatNotifier>();
            var configProvider = CreateFakeConfigurationProvider();
            var notificationHandler = new NotificationHandler(notifier, configProvider);
            var buildEvent = new BuildCompletionEvent
                                 {
                                     CompletionStatus = "Successfully Completed",
                                     TeamProject = "AnotherTestProject"
                                 };

            notificationHandler.HandleBuildCompletion(buildEvent);

            notifier.Received().SendBuildSuccessNotification(buildEvent, 456);
        }