예제 #1
0
        public void CheckIfNamesAreUnique()
        {
            var threadHandler = new ThreadHandler(10);

            threadHandler.StartAllCustomerThreads(_bank, _bazaar);

            for (var i = 0; i < threadHandler.Customers.Count - 1; i++)
            {
                var iName = threadHandler.Customers[i].Name;

                for (var j = i + 1; j < threadHandler.Customers.Count; j++)
                {
                    var jName = threadHandler.Customers[j].Name;
                    Assert.AreNotEqual(iName, jName);
                }
            }
        }
예제 #2
0
        /// <summary>
        ///		Starts the whole prosess of creating threads of customers and stores
        /// </summary>
        public void StartBazaar()
        {
            _threadHandler.StartAllStoresThreads(_bazaar);

            if (_bazaar.IsBazarOpen())
            {
                _threadHandler.StartAllCustomerThreads(_bank, _bazaar);

                while (_bazaar.IsBazarOpen())
                {
                    _threadHandler.GenerateExtraCustomers(_bank, _bazaar);
                }
                EndOfDay();

                Console.WriteLine("---------------------");
                Console.WriteLine("Bazaar is now closed.");
                Console.WriteLine("---------------------");
            }
        }