Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added fetch all #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ public Customer Edit(Dictionary<string, object> data)
return (Customer)entities[0];
}

public List<Customer> All(Dictionary<string, object> options = null)
{
List<Entity> entities = base.All(options);
List<Customer> customers = new List<Customer>();
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);
Expand Down
6 changes: 6 additions & 0 deletions test/src/CustomerTestCases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public static void FetchCustomerTest()
Assert.IsTrue(customer["id"] == (string)fetchedCustomer["id"]);
}

public static void GetAllCustomersTest()
{
List<Customer> result = Helper.TestGetAllCustomer();
Assert.AreNotSame(null, result);
}

public static void EditCustomerTest()
{
Customer customer = Helper.TestCreateCustomer();
Expand Down
13 changes: 13 additions & 0 deletions test/src/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,19 @@ public static Customer TestFetchCustomer(Customer customer)
return Helper.client.Customer.Fetch(id);
}

public static List<Customer> TestGetAllCustomer()
{
Dictionary<string, object> options = new Dictionary<string, object>();

DateTime endTime = DateTime.UtcNow;
DateTime startTime = endTime.Add(TimeSpan.FromHours(-1800));
options.Add("from", Utils.ToUnixTimestamp(startTime));
options.Add("to", Utils.ToUnixTimestamp(endTime));

List<Customer> customers = Helper.client.Customer.All(options);
return customers;
}

public static Customer TestEditCustomer(Customer customer)
{
// new Customer(id).Edit(data); -> makes things non-uniform
Expand Down
2 changes: 2 additions & 0 deletions test/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public static void RunAllCustomerTests(string key, string secret)
{
CustomerTestCases.Init(key, secret);

CustomerTestCases.GetAllCustomersTest();

CustomerTestCases.CreateCustomerTest();

CustomerTestCases.FetchCustomerTest();
Expand Down