Beispiel #1
0
        public void Send_Get_Delete()
        {
            var sendResponse =
                _factory.ActionSend()
                .SetText("test message")
                .SetTo(_validTestNumber)
                .SetDateSent(DateTime.Now.AddHours(2))
                .Execute();

            Assert.AreEqual(1, sendResponse.Count);
            Assert.IsTrue(sendResponse.List[0].Points > 0, "Points must be greather then 0");
            Assert.IsNotNull(sendResponse.Message);
            Assert.IsNotNull(sendResponse.Parts);

            string[] ids = new string[sendResponse.Count];

            for (int i = 0, l = 0; i < sendResponse.List.Count; i++)
            {
                if (!sendResponse.List[i].isError())
                {
                    //Nie wystąpił błąd podczas wysyłki (numer|treść|parametry... prawidłowe)
                    if (!sendResponse.List[i].isFinal())
                    {
                        //Status nie jest koncowy, może ulec zmianie
                        ids[l] = sendResponse.List[i].ID;
                        l++;
                    }
                }
            }

            var getResponse =
                _factory.ActionGet()
                .Ids(ids)
                .Execute();

            Assert.AreEqual(sendResponse.Count, getResponse.Count);
            Assert.AreEqual(_validTestNumber, getResponse.List[0].Number);
            Assert.AreEqual(sendResponse.List[0].ID, getResponse.List[0].ID);
            Assert.AreEqual(sendResponse.List[0].IDx, getResponse.List[0].IDx);
            Assert.AreEqual(sendResponse.List[0].Points, getResponse.List[0].Points);
            Assert.AreEqual(sendResponse.List[0].Status, getResponse.List[0].Status);

            var deletedResponse =
                _factory
                .ActionDelete()
                .Id(ids[0])
                .Execute();

            Assert.AreEqual(sendResponse.Count, deletedResponse.Count);
        }
Beispiel #2
0
        public void TestSms()
        {
            const string to = "46734195147";

            try
            {
                var client = new Client("*****@*****.**");
                //client.SetUsername("*****@*****.**");
                client.SetPasswordHash("07a0fbb4e40877cb77074eff3494b958");

                var smsApi = new SMSFactory(client);

                var result = smsApi.ActionSend()
                             .SetText("Test")
                             .SetTo(to)
                             .SetSender("QTransport")
                             .Execute();

                var ids = new string[result.Count];

                for (int i = 0, l = 0; i < result.List.Count; i++)
                {
                    if (result.List[i].isError())
                    {
                        continue;
                    }
                    if (result.List[i].isFinal())
                    {
                        continue;
                    }
                    ids[l] = result.List[i].ID;
                    l++;
                }

                result =
                    smsApi.ActionGet()
                    .Ids(ids)
                    .Execute();

                foreach (var status in result.List)
                {
                    System.Console.WriteLine("ID: " + status.ID + " NUmber: " + status.Number + " Points:" + status.Points + " Status:" + status.Status + " IDx: " + status.IDx);
                }

                foreach (var t in result.List)
                {
                    if (t.isError())
                    {
                        continue;
                    }

                    var deleted =
                        smsApi.ActionDelete()
                        .Id(t.ID)
                        .Execute();
                    System.Console.WriteLine("Deleted: " + deleted.Count);
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = $"{e.Message}. {e.InnerException?.Message}";
            }
        }