Exemple #1
0
        public void AddingACard()
        {
            string        cardName        = "My Amazing Card";
            IRestResponse addCardResponse = trelloClient.AddCardToList(trelloClient.GetBoardId(), cardName, trelloClient.GetListId());

            TrelloCardModel values = deserializer.Deserialize <TrelloCardModel>(addCardResponse);

            trelloClient.SetCardId(values.Id);
            trelloClient.SetCardName(values.Name);

            Assert.AreEqual(HttpStatusCode.OK, addCardResponse.StatusCode);
            Assert.AreEqual(cardName, values.Name);
            Assert.False(values.Closed);
            Assert.AreEqual(trelloClient.GetListId(), values.IdList);
            Assert.AreEqual(trelloClient.GetBoardId(), values.IdBoard);
            Assert.Zero(values.Badges["votes"]);
            Assert.Zero(values.Badges["attachments"]);

            /* Getting nested JSON objects */

            // using a Dictionary property
            //foreach (var item in values.Badges["attachmentsByType"]["trello"])
            //{
            //    Console.WriteLine("Key: " + item.Key + ", Value: " + item.Value);
            //}

            // using a dynamic property
            Assert.Zero(values.Badges["attachmentsByType"]["trello"]["board"]);
        }
Exemple #2
0
        public void UpdateCard()
        {
            string cardName = "My Amazing Card Updated!";
            Dictionary <string, string> extraParams = new Dictionary <string, string>
            {
                { "name", cardName }
            };

            IRestResponse   updateCardResponse = trelloClient.UpdateCard(trelloClient.GetBoardId(), trelloClient.GetListId(), trelloClient.GetCardId(), extraParams);
            TrelloCardModel values             = deserializer.Deserialize <TrelloCardModel>(updateCardResponse);

            Assert.AreEqual(HttpStatusCode.OK, updateCardResponse.StatusCode);
            Assert.AreEqual(cardName, values.Name);
            Assert.False(values.Closed);
            Assert.AreEqual(trelloClient.GetListId(), values.IdList);
            Assert.AreEqual(trelloClient.GetBoardId(), values.IdBoard);
            Assert.Zero(values.Badges["votes"]);
            Assert.Zero(values.Badges["attachments"]);
        }