Exemplo n.º 1
0
        public void TestExceptionThrownWhenNoMessageSet()
        {
            var builder = new FCMMessageBuilder();

            builder.SetRegistrationToken("123456");

            Assert.Throws <ArgumentException>(() => builder.Build());
        }
Exemplo n.º 2
0
        public void TestExceptionThrownWhenNoDestSet()
        {
            var builder = new FCMMessageBuilder();

            builder.SetMessage("qwert");

            Assert.Throws <ArgumentException>(() => builder.Build());
        }
Exemplo n.º 3
0
        public void TestExceptionThrownWhenTitleSetButNoMessage()
        {
            var builder = new FCMMessageBuilder();

            builder.SetTitle("qwert");
            builder.SetTopic("asdfg");

            Assert.Throws <ArgumentException>(() => builder.Build());
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        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();
        }
Exemplo n.º 12
0
        public void TestExceptionThrownWhenNothingSet()
        {
            var builder = new FCMMessageBuilder();

            Assert.Throws <ArgumentException>(() => builder.Build());
        }