public void AddNewWaiterTest()
        {
            ManagerLogInTest();

            waiterContext1 = managerDataAccess.AddWaiter(managerContext1.Id, waiterFirstName1, waiterLastName1,
                                                         waiterLogin1, waiterPassword1);

            Assert.IsNotNull(waiterContext1);
            Assert.AreNotEqual(waiterContext1.Id, 0);
            Assert.AreEqual(waiterContext1.FirstName, waiterFirstName1);
            Assert.AreEqual(waiterContext1.LastName, waiterLastName1);
            Assert.AreEqual(waiterContext1.Login, waiterLogin1);

            ManagerLogOutTest();
        }
示例#2
0
        public UserContext AddWaiter(string login, string firstName, string lastName, string password)
        {
            UserContext addingWaiter;

            try
            {
                addingWaiter = _managerDataAccess.AddWaiter(firstName, lastName, login, ClassLib.DataStructures.HashClass.CreateFirstHash(password, login));
            }
            catch (Exception e)
            {
                throw new Exception("Exception from DB");
            }

            return(addingWaiter);
        }
示例#3
0
        private static void DatabaseDataFill(IDataWipe dataWipe, IManagerDataAccess managerDataAccess)
        {
            try
            {
                string catName1 = "Napoje wysokoprocentowe";
                string catDescription1 = "Kiedy piwo po prostu nie wystarcza.";
                Console.Write("=> Adding MenuItemCategory Name = {0}, Description = {1}...", catName1, catDescription1);
                MenuItemCategory cat1 = managerDataAccess.AddMenuItemCategory(catName1, catDescription1);
                Console.WriteLine("Done.");

                string catName2 = "Napoje niskoprocentowe";
                string catDescription2 = "Każda okazja jest dobra.";
                Console.Write("=> Adding MenuItemCategory Name = {0}, Description = {1}...", catName2, catDescription2);
                MenuItemCategory cat2 = managerDataAccess.AddMenuItemCategory(catName2, catDescription2);
                Console.WriteLine("Done.");

                string catName3 = "Napoje bezalkoholowe";
                string catDescription3 = "Przegrałeś zakład albo musisz prowadzić.";
                Console.Write("=> Adding MenuItemCategory Name = {0}, Description = {1}...", catName3, catDescription3);
                MenuItemCategory cat3 = managerDataAccess.AddMenuItemCategory(catName3, catDescription3);
                Console.WriteLine("Done.");

                string menuItemName1 = "DeLuxe 55%";
                string menuItemDescription1 = "Wykwintny destylat ziem wschodnich.";
                Money menuItemPrice1 = new Money() { Amount = 25f, Currency = "PLN" };
                Console.Write("=> Adding MenuItem Name = {0}, Description = {1}, Category = {2}, Price = {3} {4}...", menuItemName1, menuItemDescription1, catName1, menuItemPrice1.Amount, menuItemPrice1.Currency);
                MenuItem menuItem1 = managerDataAccess.AddMenuItem(menuItemName1, menuItemDescription1, cat1.Id, menuItemPrice1);
                Console.WriteLine("Done.");

                string menuItemName2 = "Ciociosan";
                string menuItemDescription2 = "Ni to piwo, ni to wino...";
                Money menuItemPrice2 = new Money() { Amount = 8f, Currency = "PLN" };
                Console.Write("=> Adding MenuItem Name = {0}, Description = {1}, Category = {2}, Price = {3} {4}...", menuItemName2, menuItemDescription2, catName2, menuItemPrice2.Amount, menuItemPrice2.Currency);
                MenuItem menuItem2 = managerDataAccess.AddMenuItem(menuItemName2, menuItemDescription2, cat2.Id, menuItemPrice2);
                Console.WriteLine("Done.");

                string menuItemName3 = "Napój o smaku pomarańczowopodobnym";
                string menuItemDescription3 = "Szczerze, nie polecamy ...";
                Money menuItemPrice3 = new Money() { Amount = 2f, Currency = "PLN" };
                Console.Write("=> Adding MenuItem Name = {0}, Description = {1}, Category = {2}, Price = {3} {4}...", menuItemName3, menuItemDescription3, catName3, menuItemPrice3.Amount, menuItemPrice3.Currency);
                MenuItem menuItem3 = managerDataAccess.AddMenuItem(menuItemName3, menuItemDescription3, cat3.Id, menuItemPrice3);
                Console.WriteLine("Done.");

                int tableNumber1 = 1;
                string tableDescription1 = "Ten ładny od razu przy wyjściu";
                Console.Write("=> Adding Table Number {0}, Description = {1}...", tableNumber1, tableDescription1);
                Table table1 = managerDataAccess.AddTable(tableNumber1, tableDescription1);
                Console.WriteLine("Done.");

                int tableNumber2 = 2;
                string tableDescription2 = "Ten mniej ładny stojący na środku pomieszczenia";
                Console.Write("=> Adding Table Number {0}, Description = {1}...", tableNumber2, tableDescription2);
                Table table2 = managerDataAccess.AddTable(tableNumber2, tableDescription2);
                Console.WriteLine("Done.");

                int tableNumber3 = 3;
                string tableDescription3 = "Ta ledwo trzymająca się kupy sterta desek stojąca przy toaletach.";
                Console.Write("=> Adding Table Number {0}, Description = {1}...", tableNumber3, tableDescription3);
                Table table3 = managerDataAccess.AddTable(tableNumber3, tableDescription3);
                Console.WriteLine("Done.");

                string waiter1FirstName = "Iron";
                string waiter1LastName = "Man";
                string waiter1Login = "******";
                string waiter1Password = "******";
                Console.Write("=> Adding Waiter First name = {0}, Last name = {1}, Login = {2}, Password = {3}...", waiter1FirstName, waiter1LastName, waiter1Login, waiter1Password);
                WaiterContext waiter1 = managerDataAccess.AddWaiter(waiter1FirstName, waiter1LastName, waiter1Login, waiter1Password);
                Console.WriteLine("Done.");

                string waiter2FirstName = "Captain";
                string waiter2LastName = "America";
                string waiter2Login = "******";
                string waiter2Password = "******";
                Console.Write("=> Adding Waiter First name = {0}, Last name = {1}, Login = {2}, Password = {3}...", waiter2FirstName, waiter2LastName, waiter2Login, waiter2Password);
                WaiterContext waiter2 = managerDataAccess.AddWaiter(waiter2FirstName, waiter2LastName, waiter2Login, waiter2Password);
                Console.WriteLine("Done.");

                string waiter3FirstName = "Jan";
                string waiter3LastName = "Zagłoba";
                string waiter3Login = "******";
                string waiter3Password = "******";
                Console.Write("=> Adding Waiter First name = {0}, Last name = {1}, Login = {2}, Password = {3}...", waiter3FirstName, waiter3LastName, waiter3Login, waiter3Password);
                WaiterContext waiter3 = managerDataAccess.AddWaiter(waiter3FirstName, waiter3LastName, waiter3Login, waiter3Password);
                Console.WriteLine("Done.");
            }
            catch(Exception e)
            {
                Console.Write(" *** An error Occured. Wiping database...");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException != null ? e.InnerException.Message : String.Empty);
                WipeAllDatabaseData(dataWipe, managerDataAccess);
                Console.WriteLine("Done.");
            }
        }
示例#4
0
        private static void DatabaseDataFill(IDataWipe dataWipe, IManagerDataAccess managerDataAccess)
        {
            try
            {
                string catName1        = "Napoje wysokoprocentowe";
                string catDescription1 = "Kiedy piwo po prostu nie wystarcza.";
                Console.Write("=> Adding MenuItemCategory Name = {0}, Description = {1}...", catName1, catDescription1);
                MenuItemCategory cat1 = managerDataAccess.AddMenuItemCategory(catName1, catDescription1);
                Console.WriteLine("Done.");

                string catName2        = "Napoje niskoprocentowe";
                string catDescription2 = "Każda okazja jest dobra.";
                Console.Write("=> Adding MenuItemCategory Name = {0}, Description = {1}...", catName2, catDescription2);
                MenuItemCategory cat2 = managerDataAccess.AddMenuItemCategory(catName2, catDescription2);
                Console.WriteLine("Done.");

                string catName3        = "Napoje bezalkoholowe";
                string catDescription3 = "Przegrałeś zakład albo musisz prowadzić.";
                Console.Write("=> Adding MenuItemCategory Name = {0}, Description = {1}...", catName3, catDescription3);
                MenuItemCategory cat3 = managerDataAccess.AddMenuItemCategory(catName3, catDescription3);
                Console.WriteLine("Done.");

                string menuItemName1        = "DeLuxe 55%";
                string menuItemDescription1 = "Wykwintny destylat ziem wschodnich.";
                Money  menuItemPrice1       = new Money()
                {
                    Amount = 25f, Currency = "PLN"
                };
                Console.Write("=> Adding MenuItem Name = {0}, Description = {1}, Category = {2}, Price = {3} {4}...", menuItemName1, menuItemDescription1, catName1, menuItemPrice1.Amount, menuItemPrice1.Currency);
                MenuItem menuItem1 = managerDataAccess.AddMenuItem(menuItemName1, menuItemDescription1, cat1.Id, menuItemPrice1);
                Console.WriteLine("Done.");

                string menuItemName2        = "Ciociosan";
                string menuItemDescription2 = "Ni to piwo, ni to wino...";
                Money  menuItemPrice2       = new Money()
                {
                    Amount = 8f, Currency = "PLN"
                };
                Console.Write("=> Adding MenuItem Name = {0}, Description = {1}, Category = {2}, Price = {3} {4}...", menuItemName2, menuItemDescription2, catName2, menuItemPrice2.Amount, menuItemPrice2.Currency);
                MenuItem menuItem2 = managerDataAccess.AddMenuItem(menuItemName2, menuItemDescription2, cat2.Id, menuItemPrice2);
                Console.WriteLine("Done.");

                string menuItemName3        = "Napój o smaku pomarańczowopodobnym";
                string menuItemDescription3 = "Szczerze, nie polecamy ...";
                Money  menuItemPrice3       = new Money()
                {
                    Amount = 2f, Currency = "PLN"
                };
                Console.Write("=> Adding MenuItem Name = {0}, Description = {1}, Category = {2}, Price = {3} {4}...", menuItemName3, menuItemDescription3, catName3, menuItemPrice3.Amount, menuItemPrice3.Currency);
                MenuItem menuItem3 = managerDataAccess.AddMenuItem(menuItemName3, menuItemDescription3, cat3.Id, menuItemPrice3);
                Console.WriteLine("Done.");

                int    tableNumber1      = 1;
                string tableDescription1 = "Ten ładny od razu przy wyjściu";
                Console.Write("=> Adding Table Number {0}, Description = {1}...", tableNumber1, tableDescription1);
                Table table1 = managerDataAccess.AddTable(tableNumber1, tableDescription1);
                Console.WriteLine("Done.");

                int    tableNumber2      = 2;
                string tableDescription2 = "Ten mniej ładny stojący na środku pomieszczenia";
                Console.Write("=> Adding Table Number {0}, Description = {1}...", tableNumber2, tableDescription2);
                Table table2 = managerDataAccess.AddTable(tableNumber2, tableDescription2);
                Console.WriteLine("Done.");

                int    tableNumber3      = 3;
                string tableDescription3 = "Ta ledwo trzymająca się kupy sterta desek stojąca przy toaletach.";
                Console.Write("=> Adding Table Number {0}, Description = {1}...", tableNumber3, tableDescription3);
                Table table3 = managerDataAccess.AddTable(tableNumber3, tableDescription3);
                Console.WriteLine("Done.");

                string waiter1FirstName = "Iron";
                string waiter1LastName  = "Man";
                string waiter1Login     = "******";
                string waiter1Password  = "******";
                Console.Write("=> Adding Waiter First name = {0}, Last name = {1}, Login = {2}, Password = {3}...", waiter1FirstName, waiter1LastName, waiter1Login, waiter1Password);
                WaiterContext waiter1 = managerDataAccess.AddWaiter(waiter1FirstName, waiter1LastName, waiter1Login, waiter1Password);
                Console.WriteLine("Done.");

                string waiter2FirstName = "Captain";
                string waiter2LastName  = "America";
                string waiter2Login     = "******";
                string waiter2Password  = "******";
                Console.Write("=> Adding Waiter First name = {0}, Last name = {1}, Login = {2}, Password = {3}...", waiter2FirstName, waiter2LastName, waiter2Login, waiter2Password);
                WaiterContext waiter2 = managerDataAccess.AddWaiter(waiter2FirstName, waiter2LastName, waiter2Login, waiter2Password);
                Console.WriteLine("Done.");

                string waiter3FirstName = "Jan";
                string waiter3LastName  = "Zagłoba";
                string waiter3Login     = "******";
                string waiter3Password  = "******";
                Console.Write("=> Adding Waiter First name = {0}, Last name = {1}, Login = {2}, Password = {3}...", waiter3FirstName, waiter3LastName, waiter3Login, waiter3Password);
                WaiterContext waiter3 = managerDataAccess.AddWaiter(waiter3FirstName, waiter3LastName, waiter3Login, waiter3Password);
                Console.WriteLine("Done.");
            }
            catch (Exception e)
            {
                Console.Write(" *** An error Occured. Wiping database...");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException != null ? e.InnerException.Message : String.Empty);
                WipeAllDatabaseData(dataWipe, managerDataAccess);
                Console.WriteLine("Done.");
            }
        }