public void Task_03_Single_Priority() { var pc = new PriorityComparer <Item>("Z"); var dc = new DelegateComparer <Item>(CompareFirstName); var c = new CompositeComparer <Item>(new IComparer <Item>[] { pc, dc }); var z = new Item("Z"); c.Compare(A, z).Should().BeGreaterThan(0); c.Compare(z, A).Should().BeLessThan(0); }
public void Task_05_Priority_Sort_Descending() { var pc = new PriorityComparer <Item>("Z", "Y"); var dc = new DelegateComparer <Item>(CompareFirstNameDescending); var c = new CompositeComparer <Item>(new IComparer <Item>[] { pc, dc }); var z = new Item("Z"); var y = new Item("Y"); var array = new[] { A, z, B, A1, y }; Array.Sort(array, c); array.SequenceEqual(new[] { z, y, B, A1, A }).Should().BeTrue(); }