public void TextPropertyCanBeSet()
 {
     string expected = "Testing";
     Message value = new Message();
     Assert.IsNull(value.Text);
     value.Text = expected;
     Assert.AreEqual(expected, value.Text);
 }
Esempio n. 2
0
 private void Monitor_MessageReceived(string projectName, ThoughtWorks.CruiseControl.Remote.Message message)
 {
     // filter out unwanted messages, this should only allow messages that are not 'build' related
     // example of messages to allow : fixing the build, aborted the build, ...
     if (message.Kind == Remote.Message.MessageKind.NotDefined)
     {
         return;
     }
     trayIcon.ShowBalloonTip(5000, projectName, message.ToString(), ToolTipIcon.Info);
 }
Esempio n. 3
0
        public void AddedMessageShouldBeIncludedInProjectStatus()
        {
            mockStateManager.ExpectAndReturn("HasPreviousState", false, ProjectName);
            mockTrigger.ExpectAndReturn("NextBuild", DateTime.Now);

            Message message = new Message("foo");
            project.AddMessage(message);
            ProjectStatus status = project.CreateProjectStatus(new ProjectIntegrator(project, queue));
            Assert.AreEqual(message, status.Messages[0]);
        }
        private void ProjectMonitor_MessageReceived(string projectName, ThoughtWorks.CruiseControl.Remote.Message message)
        {
            if (MessageReceived != null)
            {
                var canInvoke = true;
                if (synchronizeInvoke is Control)
                {
                    canInvoke = !(synchronizeInvoke as Control).IsDisposed;
                }

                string caption = string.Concat("Project Name : ", projectName);

                if (canInvoke)
                {
                    synchronizeInvoke.BeginInvoke(MessageReceived, new object[] { caption, message });
                }
            }
        }
        public void AllStatusMessagesReturnsMustReturnThemAll()
		{
			Message latestMessage = new Message("latest message");
            Message firstMessage = new Message("message");


			ProjectStatus oldProjectStatus = ProjectStatusFixture.New("test project");
			oldProjectStatus.Messages = new Message[] {};
			ProjectStatus newProjectStatus = ProjectStatusFixture.New("test project");
            newProjectStatus.Messages = new Message[] { firstMessage, latestMessage };
			PollIntervalReporter pollIntervalReporter = new PollIntervalReporter(newProjectStatus, newProjectStatus);

            System.Text.StringBuilder expected = new System.Text.StringBuilder();
            expected.AppendLine(firstMessage.Text);
            expected.Append(latestMessage.Text);


			Assert.AreEqual(new Message(expected.ToString()), pollIntervalReporter.AllStatusMessages);
		}
        /// <summary>
        /// Conerts a <see cref="Message.MessageKind"/> to a <see cref="BuildMessageType"/>.
        /// </summary>
        /// <param name="kind">The <see cref="Message.MessageKind"/>.</param>
        /// <returns>
        /// The <see cref="BuildMessageType"/>.
        /// </returns>
        private static BuildMessageType Convert(Message.MessageKind kind)
        {
            switch (kind)
            {
                case Message.MessageKind.Breakers:
                    return BuildMessageType.Breakers;

                case Message.MessageKind.BuildAbortedBy:
                    return BuildMessageType.BuildAbortedBy;

                case Message.MessageKind.BuildStatus:
                    return BuildMessageType.BuildStatus;

                case Message.MessageKind.FailingTasks:
                    return BuildMessageType.FailingTasks;

                case Message.MessageKind.Fixer:
                    return BuildMessageType.Fixer;
            }

            return BuildMessageType.Unknown;
        }
Esempio n. 7
0
 public void SendMessage(string projectName, Message message)
 {
     MessageRequest request = new MessageRequest();
     request.ProjectName = projectName;
     request.Message = message.Text;
     request.Kind = message.Kind;
     Response resp = cruiseServer.SendMessage(request);
     ValidateResponse(resp);
 }
Esempio n. 8
0
 /// <summary>
 /// Clears the message array of the messages of the specified kind
 /// </summary>
 /// <param name="kind"></param>
 private void ClearMessages(Message.MessageKind kind)
 {
     for (Int32 i = messages.Count - 1; i >= 0; i--)
     {
         Message m = (Message)messages[i];
         if (m.Kind == kind)
         {
             messages.RemoveAt(i);
         }
     }
 }
Esempio n. 9
0
 private void Monitor_MessageReceived(string projectName, ThoughtWorks.CruiseControl.Remote.Message message)
 {
     trayIcon.ShowBalloonTip(5000, projectName, message.ToString(), ToolTipIcon.Info);
 }
        /// <summary>
        /// Sends a message for a project.
        /// </summary>
        /// <param name="projectName">The name of the project to use.</param>
        /// <param name="message"></param>
        public override void SendMessage(string projectName, Message message)
        {
            if (string.IsNullOrEmpty(projectName)) throw new ArgumentNullException("projectName");

            MessageRequest request = new MessageRequest();
            request.SessionToken = SessionToken;
            request.ProjectName = projectName;
            request.Message = message.Text;
            request.Kind = message.Kind;
            request.ServerName = TargetServer;
            Response resp = connection.SendMessage("SendMessage", request);
            ValidateResponse(resp);
        }
Esempio n. 11
0
 /// <summary>
 /// Send a text message to the server.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public virtual Response SendMessage(MessageRequest request)
 {
     Response response = RunProjectRequest(request,
         SecurityPermission.SendMessage,
         SecurityEvent.SendMessage,
         delegate(ProjectRequest arg, Response resp)
         {
             // Perform the actual send message
             Log.Info("New message received: " + request.Message);
             Message message = new Message(request.Message,request.Kind );
             if (!FireSendMessageReceived(arg.ProjectName, message))
             {
                 LookupProject(arg.ProjectName).AddMessage(message);
                 FireSendMessageProcessed(arg.ProjectName, message);
             }
         });
     return response;
 }
 public void EqualsReturnsFalseIfTypeIsDifferent()
 {
     var msg1 = new Message("The message", Message.MessageKind.NotDefined);
     var msg2 = new Message("The message", Message.MessageKind.Fixer);
     Assert.IsFalse(msg1.Equals(msg2));
 }
 public void GetHashCodeReturnsStringHashCode()
 {
     var msg = new Message("A message");
     var hashCode = msg.GetHashCode();
     Assert.AreEqual(msg.ToString().GetHashCode(), msg.GetHashCode());
 }
Esempio n. 14
0
 public void AddMessage(Message message)
 {
     messages.Add(message);
 }
 public void StartANewBlankMessage()
 {
     Message value = new Message();
     Assert.IsNull(value.Text);
 }
 /// <summary>
 /// Sends a message for a project.
 /// </summary>
 /// <param name="projectName">The name of the project to use.</param>
 /// <param name="message"></param>
 public override void SendMessage(string projectName, Message message)
 {
     manager.SendMessage(projectName, message);
 }
		public void OnMessageReceived( Message message )
		{
			if (MessageReceived != null)
				MessageReceived( message );
		}
		private void Monitor_MessageReceived(string projectName, Message message)
		{
            if (MessageReceived != null) MessageReceived(projectName, message);
		}
Esempio n. 19
0
 public void MessagesReturnsMessagesFromStatus()
 {
     var client = mocks.DynamicMock<CruiseServerClientBase>();
     var server = InitialiseServer();
     var messages = new Message[] {
         new Message { Text = "Testing"}
     };
     var status = new ProjectStatus { Messages = messages };
     var project = new Project(client, server, status);
     mocks.ReplayAll();
     Assert.AreSame(status.Messages, project.Messages);
 }
 public void StartANewMessageWithText()
 {
     string expected = "Testing";
     Message value = new Message(expected);
     Assert.AreEqual(expected, value.Text);
 }
 public void AddMessage(Message message)
 {
     throw new NotImplementedException();
 }
 public void ToStringReturnsMessage()
 {
     string expected = "Testing";
     Message value = new Message(expected);
     Assert.AreEqual(expected, value.ToString());
 }
		public void DisplayBalloonMessageWhenNewMessageIsReceived()
		{
			ProjectStatus initial = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);
            mockProjectManager.ExpectAndReturn("ProjectName", PROJECT_NAME);
            mockServerMonitor.ExpectAndReturn("GetProjectStatus", initial, PROJECT_NAME);

			Message expectedMessage = new Message("foo");
			ProjectStatus newStatus = ProjectStatusFixture.New(IntegrationStatus.Success, ProjectActivity.Sleeping);
			newStatus.Messages = new Message[] {expectedMessage};
            mockProjectManager.ExpectAndReturn("ProjectName", PROJECT_NAME);
            mockServerMonitor.ExpectAndReturn("GetProjectStatus", newStatus, PROJECT_NAME);

            monitor.MessageReceived += new MessageEventHandler(OnMessageReceived);
			monitor.Poll();
			monitor.Poll();
			Assert.AreEqual(actualMessage, expectedMessage);
		}
 public void EqualsReturnsTrueWhenBothMessageAndKindAreSame()
 {
     var msg1 = new Message("The message", Message.MessageKind.NotDefined);
     var msg2 = new Message("The message", Message.MessageKind.NotDefined);
     Assert.IsTrue(msg1.Equals(msg2));
 }
		private void OnMessageReceived(string projectName, Message message)
		{
			actualMessage = message;
		}
 public void EqualsReturnsFalseIfArgumentIsNotAMessage()
 {
     var msg1 = new Message("The message", Message.MessageKind.NotDefined);
     var msg2 = "A message";
     Assert.IsFalse(msg1.Equals(msg2));
 }
		public void TearDown()
		{
			mockProjectManager.Verify();
			actualMessage = null;
		}
		public void OnMessageReceived(string projectName, Message message )
		{
			if (MessageReceived != null)
				MessageReceived(projectName, message );
		}
Esempio n. 29
0
 public void GetHashCodeWithNullMessage()
 {
     var msg = new Message(null, Message.MessageKind.BuildAbortedBy);
     Assert.AreEqual(msg.ToString().GetHashCode(), msg.GetHashCode());
 }
Esempio n. 30
0
 private string GetMessageText(Message.MessageKind messageType)
 {
     foreach (Message m in status.Messages)
     {
         if (m.Kind == messageType)
         {
             return m.Text;
         }
     }
     return string.Empty;
 }
        public void SendMessageCanBeCancelled()
        {
            string projectName = "Project 1";
            Message message = new Message("This is a test message");
            bool sendMessageReceived = false;
            server.SendMessageReceived += delegate(object o, CancelProjectEventArgs<Message> e)
            {
                sendMessageReceived = true;
                Assert.AreEqual(projectName, e.ProjectName);
                Assert.AreEqual(message.Text, e.Data.Text);
                e.Cancel = true;
            };

            server.SendMessageProcessed += delegate(object o, ProjectEventArgs<Message> e)
            {
                Assert.Fail("SendMessageProcessed has been fired");
            };

            server.CruiseManager.SendMessage(projectName, message);
            Assert.IsTrue(sendMessageReceived, "SendMessageReceived not fired");
        }
		private void Monitor_MessageReceived(string projectName, Message message)
		{
			Notification notification = new Notification(ApplicationName, "Message", null, projectName, message.ToString());
			growl.Notify(notification);
		}
 /// <summary>
 /// Fires the SendMessageProcessed event.
 /// </summary>
 /// <param name="projectName">The name of the project.</param>
 /// <param name="message">The message that was sent.</param>
 protected virtual void FireSendMessageProcessed(string projectName, Message message)
 {
     if (SendMessageProcessed != null)
     {
         ProjectEventArgs<Message> args = new ProjectEventArgs<Message>(projectName, message);
         SendMessageProcessed(this, args);
     }
 }