public void ListOrdersShouldSucceedWhenMorePagesQueriedThanExist() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>(successfulResponses, expectedRequestBaseUrl); var orders = client.ListOrders("not_checking_this", locationId, 1, 10); // Note that we specify pages 1-10 when only 3 pages exist Assert.AreEqual(orders.Count, 9); }
public void ListFilteredOrdersShouldSucceedWithNoModifierFunctions() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>( successfulResponses, expectedRequestBaseUrl); var orders = client.ListFilteredOrders("not_checking_this", locationId, 1, 3); Assert.AreEqual(orders.Count, 9); }
public void ListOrdersShouldFailWith204ForInvalidStartPageNumbers() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>( successfulResponses, expectedRequestBaseUrl); var orders = client.ListOrders("not_checking_this", locationId, 5, 10); Assert.AreEqual(orders.Count, 0); }
public void ListOrders() { CompletedOrderResponse created = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(); IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>(); var orders = queryInterface.ListOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, 1, 3); Assert.IsNotNull(orders.Where(x => x.OrderIdentifier == created.OrderIdentifier).DefaultIfEmpty(null).FirstOrDefault()); }
public void ListFilteredOrdersShouldSucceedWithAnOrderingFunction() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>( successfulResponses, expectedRequestBaseUrl); var orders = client.ListFilteredOrders("not_checking_this", locationId, 1, 3, null, ((x, y) => (0 - string.Compare(x.OrderIdentifier, y.OrderIdentifier)))); // i.e. orderbydecending Assert.AreEqual(orders.Count, 9); Assert.AreEqual(orders[0].OrderIdentifier, "i"); Assert.AreEqual(orders[8].OrderIdentifier, "a"); }
public void ListFilteredOrdersShouldSucceedWithAFilterFunction() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>( successfulResponses, expectedRequestBaseUrl); var orders = client.ListFilteredOrders("not_checking_this", locationId, 1, 3, (x => (x.OrderIdentifier == "c" || x.OrderIdentifier == "i")), null); Assert.AreEqual(orders.Count, 2); Assert.AreEqual(orders[0].OrderIdentifier, "c"); Assert.AreEqual(orders[1].OrderIdentifier, "i"); }
public void ListOrdersShouldSucceedDespiteInvalidEndPageNumbers() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>(successfulResponses, expectedRequestBaseUrl); var orders = client.ListOrders("not_checking_this", locationId, 1, 10); Assert.AreEqual(orders.Count, 9); orders = client.ListOrders("not_checking_this", locationId, 3, 11); Assert.AreEqual(orders.Count, 3); }
public void ListFilteredOrders_WithFilter() { IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>(); CompletedOrderResponse first = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(200); ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(300); // ensure that there is at least one other order that the filter will ignore. var orders = queryInterface.ListFilteredOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, 1, 1, (x => x.OrderIdentifier == first.OrderIdentifier)); Assert.AreEqual(orders.Count, 1); Assert.IsTrue(orders.First().OrderIdentifier == first.OrderIdentifier); }
public void ListFilteredOrders_WithOrdering() { IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>(); ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(200); ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(300); var orders = queryInterface.ListFilteredOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, 1, 1, null, ((x, y) => y.Total - x.Total)); var copy = new List <OrderDetailsResponse>(orders); Assert.IsTrue(copy.OrderByDescending((x => x.Total)).SequenceEqual(orders)); }
public void ListFilteredOrders_WithFilterAndOrdering() { IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>(); CompletedOrderResponse first = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(200); CompletedOrderResponse second = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(300); var orders = queryInterface.ListFilteredOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, 1, 1, (x => x.OrderIdentifier == first.OrderIdentifier || x.OrderIdentifier == second.OrderIdentifier), ((x, y) => y.Total - x.Total)); Assert.AreEqual(orders.Count, 2); Assert.IsTrue(orders[0].OrderIdentifier == second.OrderIdentifier); Assert.IsTrue(orders[1].OrderIdentifier == first.OrderIdentifier); }
public void ListOrdersShouldSucceedWhenAllPagesQueried() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>(successfulResponses, expectedRequestBaseUrl); var orders = client.ListOrders("not_checking_this", locationId, 1, 3); Assert.AreEqual(orders.Count, 9); Assert.AreEqual(orders[0].OrderIdentifier, "a"); Assert.AreEqual(orders[1].OrderIdentifier, "b"); Assert.AreEqual(orders[2].OrderIdentifier, "c"); Assert.AreEqual(orders[3].OrderIdentifier, "d"); Assert.AreEqual(orders[4].OrderIdentifier, "e"); Assert.AreEqual(orders[5].OrderIdentifier, "f"); Assert.AreEqual(orders[6].OrderIdentifier, "g"); Assert.AreEqual(orders[7].OrderIdentifier, "h"); Assert.AreEqual(orders[8].OrderIdentifier, "i"); }
private List <OrderDetailsResponse> GetFirstThreePagesOfOrdersForTestMerchant() { IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>(); var retval = new List <OrderDetailsResponse>(); int currentPage = 1; bool areThereMorePages = true; while (areThereMorePages && currentPage < 4) { var orders = queryInterface.ListOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, currentPage, currentPage, out areThereMorePages); retval.AddRange(orders); currentPage++; } return(retval); }
public void ListOrdersShouldSucceedAndAreThereMorePagesShouldBeValid() { IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging <IQueryOrders>(successfulResponses, expectedRequestBaseUrl); bool areThereMorePages; var orders = client.ListOrders("not_checking_this", locationId, 1, 1, out areThereMorePages); Assert.IsTrue(areThereMorePages); orders = client.ListOrders("not_checking_this", locationId, 1, 3, out areThereMorePages); Assert.IsFalse(areThereMorePages); orders = client.ListOrders("not_checking_this", locationId, 3, 3, out areThereMorePages); Assert.IsFalse(areThereMorePages); orders = client.ListOrders("not_checking_this", locationId, 2, 5, out areThereMorePages); Assert.IsFalse(areThereMorePages); }