public void Text() { HipchatMessage message = parser.Parse("::text message is text"); Assert.Equal("message is text", message.Contents); Assert.Equal("text", message.Format); }
public void Notify() { HipchatMessage message = parser.Parse("::notify this message will notify"); Assert.Equal("this message will notify", message.Contents); Assert.True(message.Notify); }
public void Html() { HipchatMessage message = parser.Parse("::html message is html"); Assert.Equal("message is html", message.Contents); Assert.Equal("html", message.Format); }
public void Format() { HipchatMessage message = parser.Parse("::format html And this is <b>bold</b>"); Assert.Equal("And this is <b>bold</b>", message.Contents); Assert.Equal("html", message.Format); }
public void BackgroundColor() { HipchatMessage message = parser.Parse("::background yellow And this is my message"); Assert.Equal("And this is my message", message.Contents); Assert.Equal("yellow", message.BackgroundColor); }
public async System.Threading.Tasks.Task HipchatClientThrowsExceptionWhenRoomIsMissing() { const string room = ""; var message = new HipchatMessage(); var exception = await Assert.ThrowsAsync <RoomMissingException>(() => new HipchatClient("secure_token").SendNotificationAsync(room, message)); Assert.Equal("HipchatClient failure: Room name or id is missing.", exception.Message); }
public void Combined() { HipchatMessage message = parser.Parse("::background yellow ::format text ::from mmbot ::notify Message has all the things"); Assert.Equal("yellow", message.BackgroundColor); Assert.Equal("text", message.Format); Assert.Equal("mmbot", message.From); Assert.True(message.Notify); Assert.Equal("Message has all the things", message.Contents); }
public void From() { HipchatMessage message = parser.Parse("::from bitbucket Message from bitbucket"); Assert.Equal("bitbucket", message.From); }
public HipchatMessage Parse(string raw) { raw = raw.Trim(); if (!raw.StartsWith("::")) { return(new HipchatMessage { Contents = raw, Format = "text" }); } HipchatMessage message = new HipchatMessage(); WordParser parser = new WordParser(raw); while (true) { if (parser.NextWordMatch("::background")) { parser.Pop(); message.BackgroundColor = parser.Pop(); } else if (parser.NextWordMatch("::format")) { parser.Pop(); message.Format = parser.Pop(); } else if (parser.NextWordMatch("::html")) { parser.Pop(); message.Format = "html"; } else if (parser.NextWordMatch("::text")) { parser.Pop(); message.Format = "text"; } else if (parser.NextWordMatch("::from")) { parser.Pop(); message.From = parser.Pop(); } else if (parser.NextWordMatch("::notify")) { parser.Pop(); message.Notify = true; } else if (parser.NextWordMatch("::yellow", "::red", "::green", "::purple", "::gray", "::random")) { var value = parser.Pop(); message.BackgroundColor = value.Substring(2); } else { break; } } message.Contents = parser.Remainder; return(message); }