public void Serializes_TileSquareBlock() { // Arrange TileBinding binding = new TileBinding(new TileText { Id = 1, Text = "Text Field 1 (block text)" }, new TileText { Id = 2, Text = "Text Field 2" }) { Template = "TileSquareBlock" }; WindowsPushMessage winNot = new WindowsPushMessage(1, binding); // Act string actual = winNot.ToString(); // Assert Assert.Equal(Templates["TileSquareBlock"], actual); }
public void Serializes_TileSquareImage() { // Arrange TileBinding binding = new TileBinding(new TileImage { Id = 1, Src = "image1", Alt = "alt text" }) { Template = "TileSquareImage" }; WindowsPushMessage winNot = new WindowsPushMessage(1, binding); // Act string actual = winNot.ToString(); // Assert Assert.Equal(Templates["TileSquareImage"], actual); }
public void XmlPayload_TakesOverSerialization() { // Arrange WindowsPushMessage winNot = new WindowsPushMessage() { XmlPayload = "text" }; // Act string actual = winNot.ToString(); // Assert Assert.Equal("text", actual); }
public void Serializes_TileWide310X150PeekImageCollection01() { // Arrange Collection <TileImage> images = new Collection <TileImage> { new TileImage { Id = 1, Src = "image1.png", Alt = "larger image" }, new TileImage { Id = 2, Src = "image2.png", Alt = "small image, row 1, column 1" }, new TileImage { Id = 3, Src = "image3.png", Alt = "small image, row 1, column 2" }, new TileImage { Id = 4, Src = "image4.png", Alt = "small image, row 2, column 1" }, new TileImage { Id = 5, Src = "image5.png", Alt = "small image, row 2, column 2" }, }; Collection <TileText> texts = new Collection <TileText> { new TileText { Id = 1, Text = "Text Field 1 (larger text)" }, new TileText { Id = 2, Text = "Text Field 2" }, }; TileBinding binding = new TileBinding(images, texts) { Template = "TileWide310x150PeekImageCollection01", Fallback = "TileWidePeekImageCollection01" }; WindowsPushMessage winNot = new WindowsPushMessage(2, binding); // Act string actual = winNot.ToString(); // Assert Assert.Equal(Templates["TileWide310x150PeekImageCollection01"], actual); }
public async Task<HttpResponseMessage> Post() { var data = await this.Request.Content.ReadAsAsync<JObject>(); var method = (string)data["method"]; if (method == null) { return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest); } if (method == "send") { var serialize = new JsonSerializer(); var token = (string)data["token"]; if (data["payload"] == null || token == null) { return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest); } // Payload could be a string or a dictionary var payloadString = data["payload"].ToString(); var type = (string)data["type"]; var tag = (string)data["tag"]; if (type == "template") { TemplatePushMessage message = new TemplatePushMessage(); var payload = JObject.Parse(payloadString); var keys = payload.Properties(); foreach (JProperty key in keys) { this.traceWriter.Info("Key: " + key.Name); message.Add(key.Name, (string)key.Value); } var result = await this.pushClient.SendAsync(message); } else if (type == "gcm") { GooglePushMessage message = new GooglePushMessage(); message.JsonPayload = payloadString; var result = await this.pushClient.SendAsync(message); } else if (type == "apns") { ApplePushMessage message = new ApplePushMessage(); this.traceWriter.Info(payloadString.ToString()); message.JsonPayload = payloadString.ToString(); var result = await this.pushClient.SendAsync(message); } else if (type == "wns") { var wnsType = (string)data["wnsType"]; WindowsPushMessage message = new WindowsPushMessage(); message.XmlPayload = payloadString; message.Headers.Add("X-WNS-Type", type + '/' + wnsType); if (tag != null) { await this.pushClient.SendAsync(message, tag); } else { await this.pushClient.SendAsync(message); } } } else { return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest); } return new HttpResponseMessage(System.Net.HttpStatusCode.OK); }
public void Serializes_TileWidePeekImageCollection01() { // Arrange Collection<TileImage> images = new Collection<TileImage> { new TileImage { Id = 1, Src = "image1.png", Alt = "larger image" }, new TileImage { Id = 2, Src = "image2.png", Alt = "small image, row 1, column 1" }, new TileImage { Id = 3, Src = "image3.png", Alt = "small image, row 1, column 2" }, new TileImage { Id = 4, Src = "image4.png", Alt = "small image, row 2, column 1" }, new TileImage { Id = 5, Src = "image5.png", Alt = "small image, row 2, column 2" }, }; Collection<TileText> texts = new Collection<TileText> { new TileText { Id = 1, Text = "Text Field 1 (larger text)" }, new TileText { Id = 2, Text = "Text Field 2" }, }; TileBinding binding = new TileBinding(images, texts) { Template = "TileWidePeekImageCollection01" }; WindowsPushMessage winNot = new WindowsPushMessage(1, binding); // Act string actual = winNot.ToString(); // Assert Assert.Equal(Templates["TileWidePeekImageCollection01"], actual); }