public void TestExceptionThrownWhenNoMessageSet() { var builder = new FCMMessageBuilder(); builder.SetRegistrationToken("123456"); Assert.Throws <ArgumentException>(() => builder.Build()); }
public void TestExceptionThrownWhenNoDestSet() { var builder = new FCMMessageBuilder(); builder.SetMessage("qwert"); Assert.Throws <ArgumentException>(() => builder.Build()); }
public void TestExceptionThrownWhenTitleSetButNoMessage() { var builder = new FCMMessageBuilder(); builder.SetTitle("qwert"); builder.SetTopic("asdfg"); Assert.Throws <ArgumentException>(() => builder.Build()); }
public void TestRegTokenSet() { var regToken = "qwerty"; var builder = new FCMMessageBuilder(); builder.SetRegistrationToken(regToken); builder.SetMessage("empty"); var res = builder.Build(); Assert.That(res.To, Is.EqualTo(regToken)); }
public void TestTopicSet() { var topic = "qwerty"; var builder = new FCMMessageBuilder(); builder.SetTopic(topic); builder.SetMessage("empty"); var res = builder.Build(); Assert.That(res.To, Is.EqualTo("/topics/" + topic)); }
private static void SendNotification(string fcmServerKey, string registrationToken) { var client = new FCMClient(fcmServerKey); var builder = new FCMMessageBuilder(); var message = "HOLA"; builder.SetMessage(message); builder.SetRegistrationToken(registrationToken); builder.SetTitle("AMİGO"); var msg = builder.Build(); client.PostMessage(msg).Wait(); }
public void TestTopicOverWritesRegToken() { var regToken = "qwerty"; var topic = "asdfg"; var builder = new FCMMessageBuilder(); builder.SetRegistrationToken(regToken); builder.SetTopic(topic); builder.SetMessage("empty"); var res = builder.Build(); Assert.That(res.To, Is.EqualTo("/topics/" + topic)); }
public void TestRegistrationIdsSet() { var regIds = new List <string> { "1234", "4567", "7890" }; var builder = new FCMMessageBuilder(); builder.SetMessage("empty"); builder.SetRegistrationIds(regIds); var res = builder.Build(); Assert.That(res.To, Is.Null); Assert.That(res.Registration_Ids, Is.EquivalentTo(regIds)); }
public void TestBodySet() { var topic = "qwerty"; var builder = new FCMMessageBuilder(); builder.SetTopic(topic); var message = "ghjkl"; builder.SetMessage(message); var res = builder.Build(); Assert.That(res.Notification.Body, Is.EqualTo(message)); }
public void TestTitleSet() { var topic = "qwerty"; var builder = new FCMMessageBuilder(); builder.SetTopic(topic); var title = "ghjkl"; builder.SetTitle(title); builder.SetMessage("empty"); var res = builder.Build(); Assert.That(res.Notification.Title, Is.EqualTo(title)); }
static void Main(string[] args) { var fcmServerKey = "<ADD THIS>"; var client = new FCMClient(fcmServerKey); var registrationToken = "<ADD THIS>"; var message = "Test"; var builder = new FCMMessageBuilder(); builder.SetMessage(message); builder.SetRegistrationToken(registrationToken); var msg = builder.Build(); client.PostMessage(msg).Wait(); }
public void TestExceptionThrownWhenNothingSet() { var builder = new FCMMessageBuilder(); Assert.Throws <ArgumentException>(() => builder.Build()); }