From 5f335b8292b883c4ebd15b867b6e280bac8e4923 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Tue, 21 Jun 2022 16:20:25 +0530 Subject: [PATCH] added fetch all --- src/Customer.cs | 11 +++++++++++ test/src/CustomerTestCases.cs | 6 ++++++ test/src/Helper.cs | 13 +++++++++++++ test/src/Program.cs | 2 ++ 4 files changed, 32 insertions(+) diff --git a/src/Customer.cs b/src/Customer.cs index 1a717e8..727bae4 100644 --- a/src/Customer.cs +++ b/src/Customer.cs @@ -28,6 +28,17 @@ public Customer Edit(Dictionary data) return (Customer)entities[0]; } + public List All(Dictionary options = null) + { + List entities = base.All(options); + List customers = new List(); + foreach (Entity entity in entities) + { + customers.Add(entity as Customer); + } + return customers; + } + public Token Token(string tokenId) { string relativeUrl = string.Format("{0}/{1}/tokens/{2}", GetEntityUrl(), this["id"], tokenId); diff --git a/test/src/CustomerTestCases.cs b/test/src/CustomerTestCases.cs index d6e486d..03031ea 100644 --- a/test/src/CustomerTestCases.cs +++ b/test/src/CustomerTestCases.cs @@ -28,6 +28,12 @@ public static void FetchCustomerTest() Assert.IsTrue(customer["id"] == (string)fetchedCustomer["id"]); } + public static void GetAllCustomersTest() + { + List result = Helper.TestGetAllCustomer(); + Assert.AreNotSame(null, result); + } + public static void EditCustomerTest() { Customer customer = Helper.TestCreateCustomer(); diff --git a/test/src/Helper.cs b/test/src/Helper.cs index 3ffcde6..7629f90 100644 --- a/test/src/Helper.cs +++ b/test/src/Helper.cs @@ -244,6 +244,19 @@ public static Customer TestFetchCustomer(Customer customer) return Helper.client.Customer.Fetch(id); } + public static List TestGetAllCustomer() + { + Dictionary options = new Dictionary(); + + DateTime endTime = DateTime.UtcNow; + DateTime startTime = endTime.Add(TimeSpan.FromHours(-1800)); + options.Add("from", Utils.ToUnixTimestamp(startTime)); + options.Add("to", Utils.ToUnixTimestamp(endTime)); + + List customers = Helper.client.Customer.All(options); + return customers; + } + public static Customer TestEditCustomer(Customer customer) { // new Customer(id).Edit(data); -> makes things non-uniform diff --git a/test/src/Program.cs b/test/src/Program.cs index 13f2175..10a6c2b 100644 --- a/test/src/Program.cs +++ b/test/src/Program.cs @@ -114,6 +114,8 @@ public static void RunAllCustomerTests(string key, string secret) { CustomerTestCases.Init(key, secret); + CustomerTestCases.GetAllCustomersTest(); + CustomerTestCases.CreateCustomerTest(); CustomerTestCases.FetchCustomerTest();