Example #1
0
        static void Main(string[] args)
        {
            var modelFaker = new Faker <User>()
                             .RuleFor(o => o.Id, f => f.Random.Number(1, 650))
                             .RuleFor(o => o.Age, f => f.Random.Number(15, 90))
                             .RuleFor(o => o.Company, f => f.Company.CompanyName())
                             .RuleFor(o => o.IsMarried, f => f.Random.Bool())
                             .RuleFor(o => o.Name, f => f.Name.FullName())
                             .RuleFor(o => o.BirthDate, f => f.Date.Future(90));

            var allUserData = new List <User>();

            //string sortModelField = FluentInterfacePattern.Properties.Settings.Default.sortParameter;


            //var faker = new Faker("en");
            //var emailList = Enumerable.Range(1, 1000)
            //    .Select(_ => faker.Random)
            //    .ToList();


            for (int i = 0; i < 1000; i++)
            {
                var myModel = modelFaker.Generate();

                User tom = new UserBuilder()
                           .SetId(myModel.Id)
                           .SetName(myModel.Name)
                           .SetCompany(myModel.Company)
                           .SetAge(myModel.Age)
                           .SetIsMarried(myModel.IsMarried)
                           .SetBirthDate(myModel.BirthDate);
                allUserData.Add(tom);
            }


            //foreach (var element in allUserData)
            //{
            //    Console.WriteLine(element.Id + " " + element.Name + " " + element.Age);
            //}

            //allUserData.Sort(new Comparison<User>((x, y) => string.Compare(x.Name, y.Name, StringComparison.InvariantCulture)));
            //allUserData.Sort(new Comparison<User>((x, y) => string.Compare(x.Id.ToString(), y.Id.ToString(), StringComparison.InvariantCulture)));

            ShellSort     sortShell     = new ShellSort();
            BubbleSort    bubbleSort    = new BubbleSort();
            LinqSort      linqSort      = new LinqSort();
            CompareSort   compareSort   = new CompareSort();
            InsertionSort insertionSort = new InsertionSort();
            QuickSort     quickSort     = new QuickSort();

            var sortedShellCollection   = sortShell.ShellSortAlgorithm(allUserData);
            var sortedBubbleCollection  = bubbleSort.BubbleSortAlgorithm(allUserData);
            var sortedLinqCollection    = linqSort.LinqSortAlgorithm(allUserData);
            var sortedCompareCollection = compareSort.LinqSortAlgorithm(allUserData);
            var insertionSortCollection = insertionSort.InsertionSortAlgorithm(allUserData);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            var quickSortCollection = quickSort.QuickSortAlgorithm(allUserData, 0, allUserData.Count - 1);

            sw.Stop();
            Console.WriteLine("QuickSort: " + sw.ElapsedMilliseconds);

            Printers.PrintUsers(quickSortCollection);
            Console.ReadLine();

            //============================================

            Guid orderId = Guid.Parse("9043f30c-446f-421f-af70-234fe8f57c0d");

            Order order = new OrderBuilder()
                          .InitializeOrder(orderId)
                          .ValidateOrder(orderId)
                          .ProcessOrder(orderId)
                          .SaveOrder(orderId);

            Console.ReadKey();

            //============================================

            Guid     customerId = Guid.Parse("9043f30c-446f-421f-af70-234fe8f57c0d");
            Customer customer   = new Customer();

            customer
            .InitializeOrder(customerId)
            .ValidateOrder(customerId)
            .ProcessOrder()
            .SaveOrder();
            Console.ReadKey();
        }