public void SearchExtendedWarranty() { ExtendedWarrantyService service = new ExtendedWarrantyService(); ExtendedWarrantyResponse response; ExtendedWarrantyRequest request; BasicAuth auth; List<SearchProduct> products = new List<SearchProduct>() { new SearchProduct("nokia", 1550.00), new SearchProduct("xpto", 10.00), new SearchProduct("samsung", 10.00) }; request = new ExtendedWarrantyRequest(products); auth = new BasicAuth("*****@*****.**", "2948208E715B986F25A5E"); string basic = auth.ToString(); string bbasic = "Basic bG9qYW1vZGVsb0BwYWdhbWVudG9kaWdpdGFsLmNvbS5icjoyOTQ4MjA4RTcxNUI5ODZGMjVBNUU="; Assert.AreEqual<string>(basic, bbasic); response = service.SearchExtendedWarranty(request, auth); Assert.AreEqual<int>(response.code, 2); Assert.AreEqual<int>(response.products.Count, 3); ResponseProducts resp0 = response.products[0]; Assert.AreEqual<string>(resp0.description, "nokia"); Assert.AreEqual<decimal>(resp0.value, 1550.00m); Assert.IsTrue(resp0.extendedWarranty); Assert.AreEqual<string>(resp0.extendedWarrantyMessage, "Produto com garantia estendida"); Assert.AreEqual<decimal>(resp0.valueExtendedWarranty, 150.63m); Assert.IsNotNull(resp0.token); ResponseProducts resp1 = response.products[1]; Assert.AreEqual<string>(resp1.description, "xpto"); Assert.AreEqual<decimal>(resp1.value, 10.00m); Assert.IsFalse(resp1.extendedWarranty); Assert.AreEqual<string>(resp1.extendedWarrantyMessage, "Produto não elegível de garantia"); Assert.AreEqual<decimal>(resp1.valueExtendedWarranty, 0.0m); Assert.IsNull(resp1.token); ResponseProducts resp2 = response.products[2]; Assert.AreEqual<string>(resp2.description, "samsung"); Assert.AreEqual<decimal>(resp2.value, 10.00m); Assert.IsTrue(resp2.extendedWarranty); Assert.AreEqual<string>(resp2.extendedWarrantyMessage, "Produto com garantia estendida"); Assert.AreEqual<decimal>(resp2.valueExtendedWarranty, 48.85m); Assert.IsNotNull(resp2.token); }
private ExtendedWarrantyResponse searchExtendedWarranty(List<SearchProduct> products) { ExtendedWarrantyService service = new ExtendedWarrantyService(); ExtendedWarrantyRequest request = new ExtendedWarrantyRequest(products); BasicAuth auth = new BasicAuth("*****@*****.**", "2948208E715B986F25A5E"); return service.SearchExtendedWarranty(request, auth); }