public void Add_item_to_order_with_invalid_md5Hash_causes_error() { try { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api); using (var dummyImage = File.OpenRead("itemtest.jpg")) { using (var dummyImageTwo = File.OpenRead("itemtest2.jpg")) { var incorrectFileHash = Md5HashCalculator.MD5HashFile(dummyImageTwo); OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, Sizing = SizingOption.ShrinkToExactFit, Md5Hash = incorrectFileHash, Type = "4x6" }; var result = api.OrderItems.CreateWithData(order.id, itemToAdd, dummyImage); } } } catch (PwintyApiException exc) { Assert.IsNotNull(exc.Message); Assert.AreEqual(HttpStatusCode.BadRequest, exc.StatusCode); } }
public void Get_catalogue_standard() { PwintyApi api = new PwintyApi(); var cat = api.Catalogue.Get("GB", QualityLevel.PRO); Assert.IsNotNull(cat); Assert.IsTrue(cat.ShippingRates.Count > 0, "Should contain shipping rates"); Assert.IsTrue(cat.Items.Count > 0, "Should contain items"); }
protected Order CreateEmptyOrder(PwintyApi api, Payment paymentOption = Payment.InvoiceMe, string countryCode = "GB") { var result = api.Order.Create(new CreateOrderRequest() { countryCode = countryCode, payment = paymentOption, qualityLevel = QualityLevel.PRO }); Assert.IsTrue(result.id > 0); Assert.AreEqual(result.countryCode, countryCode); return result; }
public void Cancel_Order_Using_Delete_Endpoint() { PwintyApi api = new PwintyApi(); var result = api.Order.Create(new CreateOrderRequest() { countryCode = "GB", payment = Payment.InvoiceMe, qualityLevel = QualityLevel.PRO }); api.Order.Delete(result.id); var order = api.Order.Get(result.id); Assert.AreEqual(OrderStatus.Cancelled, order.status); }
protected void Add_item_to_order(PwintyApi api,long orderId,int? price = null) { using (var dummyImage = File.OpenRead("itemtest.jpg")) { OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, Sizing = SizingOption.ShrinkToExactFit, Type = "4x6", PriceToUser = price }; var result = api.OrderItems.CreateWithData(orderId, itemToAdd, dummyImage); Assert.AreEqual(OrderItemStatus.Ok, result.Status); } }
public void Submit_Order_With_Card_Declined_Card() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api, Payment.InvoiceRecipient); Add_item_to_order(api, result.id, 200); api.Order.SubmitForPayment(result.id); var paymentUrl = result.paymentUrl; Console.WriteLine("Payment url is " + paymentUrl); using (var seleniumInstance = new FirefoxDriver()) { SubmitTestPayment(seleniumInstance,result, paymentUrl); CheckOrderSummary(seleniumInstance); EnterDummyPaymentOptions(seleniumInstance,StripeCardDetails.CARD_DECLINED); AssertPaymentFailed(seleniumInstance); } }
public void Submit_Order_With_No_AddressAnd_Retrieve_Payment_Url() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrder(api, Payment.InvoiceRecipient); Add_item_to_order(api, result.id, 200); api.Order.SubmitForPayment(result.id); var paymentUrl = result.paymentUrl; Console.WriteLine("Payment url is " + paymentUrl); using (var seleniumInstance = new FirefoxDriver()) { AddAddressAndSubmitTestPayment(seleniumInstance, result, paymentUrl, "Mr Test", "test st", "test town", "Testeshire"); CheckOrderSummary(seleniumInstance); EnterDummyPaymentOptions(seleniumInstance, StripeCardDetails.VALID_VISA); AssertPaymentSuccess(seleniumInstance); } }
public void Cancel_Submitted_Order_Causes_Error() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); Add_item_to_order(api, result.id); api.Order.Submit(result.id); try { api.Order.Cancel(result.id); Assert.Fail("Should throw error when cancel submitted order"); } catch (PwintyApiException exc) { Assert.IsNotNull(exc.Message); Assert.AreEqual(HttpStatusCode.Forbidden, exc.StatusCode, "Should return status code forbidden"); } }
public void Cannot_Create_Order_Without_CountryCode() { try { PwintyApi api = new PwintyApi(); var result = api.Order.Create(new CreateOrderRequest() { payment = Payment.InvoiceRecipient, qualityLevel = QualityLevel.PRO }); Assert.Fail("Should throw error if country code not supplied"); } catch (PwintyApiException exc) { Assert.IsNotNull(exc.Message); Assert.AreEqual(HttpStatusCode.BadRequest,exc.StatusCode); } }
public void Add_item_to_order() { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api); using (var dummyImage = File.OpenRead("itemtest.jpg")) { OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, Sizing = SizingOption.ShrinkToExactFit, Type = "4x6" }; var result = api.OrderItems.CreateWithData(order.id, itemToAdd, dummyImage); Assert.AreEqual(OrderItemStatus.Ok, result.Status); Assert.AreNotEqual(0, result.Price); } }
protected Order CreateEmptyOrderWithValidAddress(PwintyApi api,Payment paymentOption = Payment.InvoiceMe,string countryCode = "GB") { var result = api.Order.Create(new CreateOrderRequest() { countryCode = countryCode, address1 = "Linton Travel Tavern", address2 = "Nr Longstanton Spice Museum", addressTownOrCity = "NORWICH", postalOrZipCode = "AGP1", recipientName = "Alan Gordan Partridge", stateOrCounty = "East Anglia", payment = paymentOption, qualityLevel = QualityLevel.PRO }); Assert.IsTrue(result.id > 0); Assert.AreEqual(result.countryCode, countryCode); return result; }
public void Adding_item_to_order_increases_cost() { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api); var originalPrice = order.price; using (var dummyImage = File.OpenRead("itemtest.jpg")) { OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, OrderId = order.id, Sizing = SizingOption.ShrinkToExactFit, Type = "4x6" }; var result = api.OrderItems.CreateWithData(order.id, itemToAdd, dummyImage); Assert.AreEqual(OrderItemStatus.Ok, result.Status); } var updatedOrder = api.Order.Get(order.id); Assert.IsTrue(updatedOrder.price > originalPrice); }
public void Get_item_by_id() { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api,Payment.InvoiceRecipient); OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, PriceToUser = 270, Sizing = SizingOption.ShrinkToExactFit, Url = "http://farm8.staticflickr.com/7046/6904409825_fd4b1482fe_b.jpg", Type = "4x6" }; var result = api.OrderItems.Create(order.id, itemToAdd); result = api.OrderItems.Get(order.id, result.Id); Assert.AreEqual(itemToAdd.Copies, result.Copies); Assert.AreEqual(itemToAdd.Sizing, result.Sizing); Assert.AreEqual(itemToAdd.Url, result.Url); Assert.AreEqual(itemToAdd.Type, result.Type); Assert.AreEqual(itemToAdd.PriceToUser, result.PriceToUser); }
public void Cant_submit_order_with_invoice_recipient() { try { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api, Payment.InvoiceRecipient); Add_item_to_order(api, result.id); api.Order.Submit(result.id); Assert.Fail("Should throw error on submit empty order"); } catch (PwintyApiException exc) { Assert.AreEqual(HttpStatusCode.BadRequest, exc.StatusCode, "Should return bad request"); } }
public void Add_item_to_order_with_md5Hash() { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api); using (var dummyImage = File.OpenRead("itemtest.jpg")) { var fileHash = Md5HashCalculator.MD5HashFile(dummyImage); OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, Sizing = SizingOption.ShrinkToExactFit, Md5Hash = fileHash, Type = "4x6" }; var result = api.OrderItems.CreateWithData(order.id, itemToAdd, dummyImage); Assert.AreEqual(OrderItemStatus.Ok, result.Status); } }
public void Check_order_submission_status() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); Add_item_to_order(api, result.id); var status = api.Order.CheckReadyForSubmit(result.id); Assert.IsTrue(status.isValid, "Order should be valid for submit"); }
public void Can_submit_order_with_invoice_me() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); Add_item_to_order(api, result.id); api.Order.Submit(result.id); }
public void Create_Order() { PwintyApi api = new PwintyApi(); var result = api.Order.Create(new CreateOrderRequest() { countryCode = "GB", payment = Payment.InvoiceRecipient, qualityLevel = QualityLevel.PRO }); Assert.IsTrue(result.id > 0); Assert.IsTrue(result.price > 0); Assert.AreEqual(Payment.InvoiceRecipient, result.payment); Assert.AreEqual(QualityLevel.PRO, result.qualityLevel); Assert.AreEqual(OrderStatus.NotYetSubmitted, result.status); Assert.IsNotNull(result.shippingInfo); Assert.IsTrue(result.shippingInfo.Price > 0); Assert.IsFalse(result.shippingInfo.isTracked); }
public void Check_order_submission_status_when_errors() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); var status = api.Order.CheckReadyForSubmit(result.id); Assert.IsFalse(status.isValid, "Order should not be valid for submit with no items"); Assert.IsTrue(status.generalErrors.Count > 0, "Order should have general errors"); }
public void Create_CanvasOrder_And_Retreive() { PwintyApi api = new PwintyApi(); var result = api.Order.Create(new CreateOrderRequest() { countryCode = "GB", payment = Payment.InvoiceRecipient, qualityLevel = QualityLevel.PRO }); OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, PriceToUser = 270, Sizing = SizingOption.ShrinkToExactFit, Url = "http://farm8.staticflickr.com/7046/6904409825_fd4b1482fe_b.jpg", Type = "C10x12" }; var newItem = api.OrderItems.Create(result.id, itemToAdd); var updatedOrder = api.Order.Get(result.id); Assert.IsTrue(updatedOrder.id > 0); Assert.IsTrue(updatedOrder.price > 0); Assert.AreEqual(Payment.InvoiceRecipient, updatedOrder.payment); Assert.AreEqual(QualityLevel.PRO, updatedOrder.qualityLevel); Assert.AreEqual(OrderStatus.NotYetSubmitted, updatedOrder.status); Assert.IsNotNull(updatedOrder.shippingInfo); Assert.IsTrue(updatedOrder.shippingInfo.Price > 0); Assert.IsTrue(updatedOrder.shippingInfo.isTracked); }
public void Submit_Order_Without_Items() { try { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); api.Order.Submit(result.id); Assert.Fail("Should throw error on submit empty order"); } catch (PwintyApiException exc) { Assert.IsNotNull(exc.Message); Assert.AreEqual(HttpStatusCode.Forbidden, exc.StatusCode); } }
public void List_Orders() { PwintyApi api = new PwintyApi(); var orders = api.Order.Get(); Assert.IsNotNull(orders); }
public void Submit_Order_And_Retrieve_Payment_Url() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api,Payment.InvoiceRecipient); Add_item_to_order(api, result.id,200); api.Order.SubmitForPayment(result.id); var paymentUrl = result.paymentUrl; Console.WriteLine("Payment url is " + paymentUrl); using (WebClient client = new WebClient()) { var webResult = client.DownloadString(paymentUrl); Console.WriteLine(webResult); } }
public void Invoice_recipient_order_returns_payment_url() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api, Payment.InvoiceRecipient); Assert.IsNotNull(result.paymentUrl, "Payment url should be available"); Add_item_to_order(api, result.id,200); api.Order.SubmitForPayment(result.id); }
public void Cant_delete_item_from_submitted_order() { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api); OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, Sizing = SizingOption.ShrinkToExactFit, Url = "http://farm8.staticflickr.com/7046/6904409825_fd4b1482fe_b.jpg", Type = "4x6" }; var result = api.OrderItems.Create(order.id, itemToAdd); api.Order.Submit(order.id); try { api.OrderItems.Delete(result.Id, order.id); Assert.Fail("Should not be able to delete photo from submitted order"); } catch (PwintyApiException exc) { Assert.AreEqual(HttpStatusCode.Forbidden, exc.StatusCode); Assert.IsNotNull(exc.Message); } order = api.Order.Get(order.id); Assert.AreEqual(1, order.photos.Count, "Should still be one photo in order"); }
public void Create_Order_Without_Country_Throws_Exception() { try { PwintyApi api = new PwintyApi(); var result = api.Order.Create(new CreateOrderRequest() { payment = Payment.InvoiceRecipient, qualityLevel = QualityLevel.PRO }); Assert.Fail("Exception should be thrown when order created without country code"); } catch (PwintyApiException exc) { Assert.IsNotNull(exc.Message); } }
public void Delete_item_from_order() { PwintyApi api = new PwintyApi(); var order = base.CreateEmptyOrderWithValidAddress(api); OrderItemRequest itemToAdd = new OrderItemRequest() { Copies = 1, Sizing = SizingOption.ShrinkToExactFit, Url = "http://farm8.staticflickr.com/7046/6904409825_fd4b1482fe_b.jpg", Type = "4x6" }; var result = api.OrderItems.Create(order.id, itemToAdd); api.OrderItems.Delete(result.Id, order.id); order = api.Order.Get(order.id); Assert.AreEqual(0, order.photos.Count, "Should be no photos left in order"); }
public void Update_order_address() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); var updateRequest = new UpdateOrderRequest() { address1 = "new address 1", id = result.id, address2 = "new address 2", addressTownOrCity = "newtown", postalOrZipCode = "NN1 1NN", recipientName = "mr new", stateOrCounty = "NEWARK" }; var updatedOrder = api.Order.Update(updateRequest); Assert.AreEqual(updateRequest.address1,updatedOrder.address1); Assert.AreEqual(updateRequest.address2,updatedOrder.address2); Assert.AreEqual(updateRequest.addressTownOrCity,updatedOrder.addressTownOrCity); Assert.AreEqual(updateRequest.postalOrZipCode,updatedOrder.postalOrZipCode); Assert.AreEqual(updateRequest.recipientName,updatedOrder.recipientName); Assert.AreEqual(updateRequest.stateOrCounty,updatedOrder.stateOrCounty); }
public void Get_Order_Photos() { PwintyApi api = new PwintyApi(); var result = CreateEmptyOrderWithValidAddress(api); Add_item_to_order(api, result.id); var photos = api.Order.GetPhotos(result.id); Assert.AreEqual(1, photos.Count); }
public void Create_International_Order() { PwintyApi api = new PwintyApi(); var result = api.Order.Create(new CreateOrderRequest() { countryCode = "GB", destinationCountryCode = "FR", payment = Payment.InvoiceRecipient, qualityLevel = QualityLevel.PRO }); Assert.IsTrue(result.id > 0); Assert.AreEqual(Payment.InvoiceRecipient, result.payment); Assert.AreEqual(QualityLevel.PRO, result.qualityLevel); Assert.AreEqual(OrderStatus.NotYetSubmitted, result.status); }