public void SortPropertyPathInaccessibleValues() { ViewFactory factory = ViewFactory.IListOrders(); ObjectListView view = factory.View; IList list = factory.List; view.ItemType = typeof(Order); Company acme = new Company("Acme", "Seattle", "WA"); Company ajax = new Company("Ajax", "Detroit", "MI"); AccountRep steve = new AccountRep("Steve O'Donnell", 56); AccountRep carol = new AccountRep("Carol Hanson", 12); AccountRep john = new AccountRep("John Roche", 10); Customer bob = new Customer("Bob Smith", acme, steve); Customer tom = new Customer("Tom Kelly", ajax, null); Customer mike = new Customer("Mike Palooza", acme, carol); Customer rick = new Customer("Rick Doohan", ajax, john); list.Add(new Order(bob, "Widgets", 10)); list.Add(new Order(bob, "Nails", 200)); list.Add(new Order(tom, "Boxes", 20)); list.Add(new Order(tom, "Gadgets", 7)); list.Add(new Order(mike, "Bolts", 3000)); list.Add(new Order(rick, "Glue", 15)); // Sort should be: // (note that the items that compare equally will be sorted in reverse of list order because the sort direction is descending) // Nails // Widgets // Bolts // Glue // Gadgets // Boxes view.Sort = "Customer.AccountRep.Department DESC"; Assert.AreEqual(6, view.Count); Assert.AreEqual("Nails", ((Order)view[0]).Product); Assert.AreEqual("Widgets", ((Order)view[1]).Product); Assert.AreEqual("Bolts", ((Order)view[2]).Product); Assert.AreEqual("Glue", ((Order)view[3]).Product); Assert.AreEqual("Gadgets", ((Order)view[4]).Product); Assert.AreEqual("Boxes", ((Order)view[5]).Product); }
public void SortPropertyPath() { ViewFactory factory = ViewFactory.IListOrders(); ObjectListView view = factory.View; IList list = factory.List; view.ItemType = typeof(Order); Company acme = new Company("Acme", "Seattle", "WA"); Company ajax = new Company("Ajax", "Detroit", "MI"); AccountRep steve = new AccountRep("Steve O'Donnell", 56); AccountRep carol = new AccountRep("Carol Hanson", 12); AccountRep john = new AccountRep("John Roche", 10); Customer bob = new Customer("Bob Smith", acme, steve); Customer tom = new Customer("Tom Kelly", ajax, carol); Customer mike = new Customer("Mike Palooza", acme, john); list.Add(new Order(bob, "Widgets", 10)); list.Add(new Order(bob, "Nails", 200)); list.Add(new Order(tom, "Boxes", 20)); list.Add(new Order(tom, "Gadgets", 7)); list.Add(new Order(mike, "Bolts", 3000)); // Sort should be: // Bolts // Boxes // Gadgets // Widgets // Nails view.Sort = "Customer.AccountRep.Department ASC"; Assert.AreEqual(5, view.Count); Assert.AreEqual("Bolts", ((Order)view[0]).Product); Assert.AreEqual("Boxes", ((Order)view[1]).Product); Assert.AreEqual("Gadgets", ((Order)view[2]).Product); Assert.AreEqual("Widgets", ((Order)view[3]).Product); Assert.AreEqual("Nails", ((Order)view[4]).Product); }
public void SelectCriteriaPathInaccessibleValue() { ViewFactory factory = ViewFactory.IListOrders(); ObjectListView view = factory.View; IList list = factory.List; view.ItemType = typeof(Order); Company acme = new Company("Acme", "Seattle", "WA"); Company ajax = new Company("Ajax", "Detroit", "MI"); AccountRep steve = new AccountRep("Steve O'Donnell", 56); AccountRep carol = new AccountRep("Carol Hanson", 12); AccountRep john = new AccountRep("John Roche", 12); Customer bob = new Customer("Bob Smith", acme, steve); Customer tom = new Customer("Tom Kelly", ajax, carol); Customer mike = new Customer("Mike Palooza", acme, john); Customer rick = new Customer("Rick Doohan", ajax, null); list.Add(new Order(bob, "Widgets", 10)); list.Add(new Order(bob, "Nails", 200)); list.Add(new Order(tom, "Boxes", 20)); list.Add(new Order(tom, "Gadgets", 7)); list.Add(new Order(mike, "Bolts", 3000)); list.Add(new Order(rick, "Glue", 15)); IList matches = view.Select("Customer.AccountRep.Department = 12 AND Customer.AccountRep.Name = Carol*"); Assert.IsNotNull(matches); Assert.AreEqual(2, matches.Count); Assert.AreEqual("Boxes", ((Order)matches[0]).Product); Assert.AreEqual("Gadgets", ((Order)matches[1]).Product); }
public void FindCriteriaPath() { ViewFactory factory = ViewFactory.IListOrders(); ObjectListView view = factory.View; IList list = factory.List; view.ItemType = typeof(Order); Company acme = new Company("Acme", "Seattle", "WA"); Company ajax = new Company("Ajax", "Detroit", "MI"); AccountRep steve = new AccountRep("Steve O'Donnell", 56); AccountRep carol = new AccountRep("Carol Hanson", 12); AccountRep john = new AccountRep("John Roche", 12); Customer bob = new Customer("Bob Smith", acme, steve); Customer tom = new Customer("Tom Kelly", ajax, carol); Customer mike = new Customer("Mike Palooza", acme, john); list.Add(new Order(bob, "Widgets", 10)); list.Add(new Order(bob, "Nails", 200)); list.Add(new Order(tom, "Boxes", 20)); list.Add(new Order(tom, "Gadgets", 7)); list.Add(new Order(mike, "Bolts", 3000)); int firstIndex = view.Find("Customer.AccountRep.Department = 12 AND Customer.AccountRep.Name = Carol*"); Assert.AreEqual(2, firstIndex); }
public Customer(string name, Company company, AccountRep rep) { this.contactName = name; this.company = company; this.rep = rep; }