public void TestList() { int limit = 5, page = 1; Customer customer = new Customer(); customer.Page = page++; customer.Limit = limit; Customer[] results = (Customer[]) customer.Read<Customer[]>(); Assert.AreEqual(limit, results.Length); }
public void TestReadById() { Customer customer = new Customer(); customer.ID = "1"; Customer[] results = (Customer[]) customer.Read<Customer>(); Assert.AreEqual(1, results.Length); Customer result = results[0]; Assert.AreEqual(customer.ID, customer.ID); }
public void TestSearch() { string search = "Smith"; Customer customer = new Customer(); customer.LastName = search; Customer[] results = (Customer[]) customer.Read<Customer>(); Assert.IsTrue(results.Length > 1); foreach (Customer o in results) { Assert.IsTrue(o.LastName.Contains(search)); } }
public bool Exists() { if (string.IsNullOrWhiteSpace(this.FirstName)) throw new InvalidProgramException("Must specify name in Customer.Exists()"); Customer customer = new Customer(); customer.FirstName = this.FirstName; customer.LastName = this.LastName; customer.AddressLine1 = this.AddressLine1; customer.AddressLine1 = this.AddressLine2; customer.CityName = this.CityName; customer.RegionName = this.RegionName; customer.Postcode = this.Postcode; Customer[] customers = (Customer[]) customer.Read<Customer[]>(); if (customers.Length > 0 && ! string.IsNullOrWhiteSpace(customers[0].FirstName)) return true; else return false; }