public void IsAvailableTest()
        {
            Program.ClearInformation();
            IRepository <Product> _productRepository = new ProductRepository();
            Product product = new Product(1, "House", "MOPRa,1", "saled");

            _productRepository.Save(product);
            bool actual   = Realtor.IsAvailable(product);
            bool expected = false;

            Assert.AreEqual(expected, actual);
            Program.ClearInformation();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            AutoFilling();
            while (true)
            {
                IRepository <Client>  _clientRepository  = new ClientRepository();
                IRepository <Product> _productRepository = new ProductRepository();
                IRepository <Manager> _managerRepository = new ManagerRepository();
                IEnumerable <Client>  clientRepository   = _clientRepository.GetItems();
                IEnumerable <Product> productRepository  = _productRepository.GetItems();
                IEnumerable <Manager> managerRepository  = _managerRepository.GetItems();
                Console.Write("The assortment of products \n");

                Realtor.PrintAssortment(productRepository);

                int countOfProducts = _productRepository.GetItems().Count();
                int countOfClients  = _clientRepository.GetItems().Count();
                int countOfManagers = _managerRepository.GetItems().Count();


                Console.WriteLine("What do you want to buy?");
                int id = 0;

                while (true)
                {
                    Realtor.ChooseProduct(ref id);
                    Realtor.ChooseManager(_managerRepository);

                    if (id < 0 || id > countOfProducts)
                    {
                        Console.WriteLine("Incorrect number. Try again. A number of products is: {0} ", countOfProducts);
                    }
                    else
                    {
                        break;
                    }
                }

                if (!Realtor.IsAvailable(_productRepository.GetItem(id)))
                {
                    Console.WriteLine("Sorry. This product is saled");
                }

                else
                {
                    Console.WriteLine("Enter your Name");
                    string name = Console.ReadLine();


                    if (!Realtor.IsExistingClient(clientRepository, name))
                    {
                        Console.WriteLine("You are new client. You will be saved in our database");
                        countOfClients += 1;
                        Realtor.RememberClient(_clientRepository, countOfClients, name);
                    }

                    Realtor.Deal(_productRepository, id);
                }
                Console.ReadKey();
                if (!Realtor.Proceed())
                {
                    break;
                }
                else
                {
                    Console.Clear();
                }
            }
        }