Esempio n. 1
0
        public void SendersGetAll()
        {
            BrickStreetConnect brickst = makeClient();

            HttpStatusCode status;
            String         statusMessage;
            List <Sender>  senders = brickst.GetSenders(out status, out statusMessage);

            Assert.AreEqual(HttpStatusCode.OK, status);
            Assert.IsNotNull(senders);

            foreach (Sender s in senders)
            {
                long   id      = s.Id.Value;
                Sender fetched = brickst.GetSender(id, out status, out statusMessage);
                Assert.AreEqual(HttpStatusCode.OK, status);
            }
        }
Esempio n. 2
0
        public void ConversationAddGetSenders()
        {
            BrickStreetConnect brickStreetConnect = makeClient();
            HttpStatusCode     status;
            string             statusMessage;

            // get sender name and domain
            Sender       defSender = null;
            SenderDomain defDomain = null;

            //
            // get default sender
            //
            List <Sender> senders = brickStreetConnect.GetSenders(out status, out statusMessage);

            Assert.AreEqual(HttpStatusCode.OK, status);
            Assert.IsNotNull(senders);
            foreach (Sender s in senders)
            {
                Sender fetched = brickStreetConnect.GetSender(s.Id.Value, out status, out statusMessage);
                Assert.AreEqual(HttpStatusCode.OK, status);
                Assert.IsNotNull(fetched);
                Assert.IsTrue(fetched.DefaultSender.HasValue);
                if (fetched.DefaultSender.Value)
                {
                    defSender = fetched;
                    break;
                }
            }
            Assert.IsNotNull(defSender);

            //
            // get default sender domain
            //
            List <SenderDomain> domains = brickStreetConnect.GetSenderDomains(out status, out statusMessage);

            Assert.AreEqual(HttpStatusCode.OK, status);
            Assert.IsNotNull(domains);
            foreach (SenderDomain d in domains)
            {
                SenderDomain fetched = brickStreetConnect.GetSenderDomain(d.Id.Value, out status, out statusMessage);
                Assert.AreEqual(HttpStatusCode.OK, status);
                Assert.IsNotNull(fetched);
                Assert.IsTrue(fetched.DefaultDomain.HasValue);
                if (fetched.DefaultDomain.Value)
                {
                    defDomain = fetched;
                    break;
                }
            }
            Assert.IsNotNull(defDomain);


            string       cname = "TEST" + DateTime.Now.Ticks.ToString();
            Conversation conv  = new Conversation
            {
                Name         = cname,
                DepartmentID = ConnectDepartmentID,
                SenderID     = defSender.Id.Value,
                SenderDomain = defDomain.Id.Value
            };

            Conversation dbConv = brickStreetConnect.AddConversation(conv, out status, out statusMessage);

            if (status != HttpStatusCode.OK)
            {
                Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage);
            }
            Assert.AreEqual(HttpStatusCode.OK, status);
            Assert.IsNotNull(dbConv);
            Assert.IsNotNull(dbConv.Id);
            Assert.AreEqual(cname, dbConv.Name);
            Assert.AreEqual(dbConv.SenderID.Value, defSender.Id.Value);
            Assert.AreEqual(dbConv.SenderDomain.Value, defDomain.Id.Value);

            //
            // test get methods
            //

            conv = brickStreetConnect.GetConversation((long)dbConv.Id, out status, out statusMessage);
            if (status != HttpStatusCode.OK)
            {
                Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage);
            }
            Assert.AreEqual(HttpStatusCode.OK, status);
            Assert.IsNotNull(conv);
            Assert.IsNotNull(conv.Id);
            Assert.AreEqual(dbConv.Name, conv.Name);
            Assert.AreEqual(dbConv.SenderID.Value, defSender.Id.Value);
            Assert.AreEqual(dbConv.SenderDomain.Value, defDomain.Id.Value);

            conv = brickStreetConnect.GetConversationByName(cname, out status, out statusMessage);
            if (status != HttpStatusCode.OK)
            {
                Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage);
            }
            Assert.AreEqual(HttpStatusCode.OK, status);
            Assert.IsNotNull(conv);
            Assert.IsNotNull(conv.Id);
            Assert.AreEqual(dbConv.Name, conv.Name);
            Assert.AreEqual(dbConv.SenderID.Value, defSender.Id.Value);
            Assert.AreEqual(dbConv.SenderDomain.Value, defDomain.Id.Value);
        }