示例#1
0
 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);
 }
示例#2
0
        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);
        }
示例#3
0
        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));
            }
        }
示例#4
0
 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;
 }