public void testGetCouriers() { List <Courier> couriers = connection.getCouriers(); //total Couriers returned Assert.IsTrue(couriers.Count > 30); //check first courier Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].slug)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].name)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].phone)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].other_name)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].web_url)); //try to acces with a bad API Key ConnectionAPI connectionBadKey = new ConnectionAPI("badKey"); try { connectionBadKey.getCouriers(); } catch (Exception e) { Assert.AreEqual("{\"meta\":{\"code\":401,\"message\":\"Invalid API key.\",\"type\":\"Unauthorized\"},\"data\":{}}", e.Message); } }
public void testGetAllCouriers() { List <Courier> couriers = connection.getAllCouriers(); //check first courier Assert.AreEqual(firstCourier["slug"], couriers[0].slug); Assert.AreEqual(firstCourier["name"], couriers[0].name); Assert.AreEqual(firstCourier["phone"], couriers[0].phone); Assert.AreEqual(firstCourier["other_name"], couriers[0].other_name); Assert.AreEqual(firstCourier["web_url"], couriers[0].web_url); //total Couriers returned Assert.AreEqual(TOTAL_COURIERS_API, couriers.Count); //try to acces with a bad API Key ConnectionAPI connectionBadKey = new ConnectionAPI("badKey"); try{ connectionBadKey.getCouriers(); }catch (Exception e) { Assert.AreEqual("{\"meta\":{\"code\":401,\"message\":\"Invalid API key.\",\"type\":\"Unauthorized\"},\"data\":{}}", e.Message); } }
public void testGetCouriers() { List<Courier> couriers = connection.getCouriers(); //total Couriers returned Assert.IsTrue(couriers.Count > 30); //check first courier Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].slug)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].name)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].phone)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].other_name)); Assert.IsTrue(!string.IsNullOrEmpty(couriers[0].web_url)); //try to acces with a bad API Key ConnectionAPI connectionBadKey = new ConnectionAPI("badKey"); try { connectionBadKey.getCouriers(); } catch (Exception e) { Assert.AreEqual("{\"meta\":{\"code\":401,\"message\":\"Invalid API key.\",\"type\":\"Unauthorized\"},\"data\":{}}", e.Message); } }