Exemple #1
0
        static void TestGenericCollection()
        {
            string testName = "GenericCollection";
            Begin(testName);
            Supplier s1 = new Supplier(1, "MyCompany", "Mark", "CEO", "1234 Here St. PO Box 123", "Dallas", "Texas", "12344", "USA", "555123123",
                    "1231231234", "www.MyCompany.com", SupplierTypes.Supply);
            Supplier s2 = new Supplier();
            s2 = new Supplier();
            s2.ID = 2;
            s2.CompanyName = "M";
            s2.ContactName = "n";
            s2.ContactTitle = "a";
            s2.Address = "b";
            s2.City = "c";
            s2.Region = "d";
            s2.PostalCode = "123";
            s2.Country = "1";
            s2.Phone = "1";
            s2.Fax = "1";
            s2.Homepage = "wwwwww";
            s2.Type = SupplierTypes.Service;

            #region Constructor Add and IEnumerable
            Test("Constructor, Add and IEnumerable");
            GenericCollection<Supplier> genericSuppliers = new GenericCollection<Supplier>();
            genericSuppliers.Add(s1);
            genericSuppliers.Add(s2);
            ShowCollection(genericSuppliers.GetEnumerator());
            #endregion

            #region CopyTo Method
            Test("CopyTo Method");
            int x = genericSuppliers.Count;
            Supplier[] supplierArray = new Supplier[x];
            genericSuppliers.CopyTo(supplierArray,0);
            ShowCollection(supplierArray.GetEnumerator());
            #endregion

            #region Sort Array on TypeCompanyName
            Test("Sort Array on TypeCompanyName");
            Array.Sort(supplierArray, Supplier.GetSortByTypeCompanyName());
            ShowCollection(supplierArray.GetEnumerator());
            #endregion
            End(testName);
            Wait();
        }