Ejemplo n.º 1
0
        public void Parse_multiple_products_separated_with_a_comma()
        {
            var cashRegister = new CashRegister();
            var price        = cashRegister.Add("Pommes, Cerises, Bananes");

            Check.That(price).IsEqualTo(325);
        }
        public void CanSuccessfullyCheckoutShoppingCart()
        {
            // Arrange
            var shoppingCart = new ShoppingCart
            {
                Items = new List <Item>
                {
                    new Item {
                        Sku = "A"
                    },
                    new Item {
                        Sku = "B"
                    },
                    new Item {
                        Sku = "C"
                    },
                    new Item {
                        Sku = "D"
                    }
                }
            };
            var cashRegister = new CashRegister
            {
                Supermarket  = _supermarket,
                ShoppingCart = shoppingCart
            };

            // Act
            var totalPrice = cashRegister.ComputeTotalPrice();

            // Assert
            Assert.AreEqual(115, totalPrice);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The method checks what cash register is the most available (the least customers in line) and returns it.
        /// </summary>
        public static CashRegister MostAvailableCashRegister()
        {
            CashRegister cr = null;

            if (SupermarketDB.Instance.GetCashRegisters().Count == 0)
            {
                return(null);
            }
            if (OpenedCashRegisters().Count == 0)
            {
                return(null);
            }
            else
            {
                int MinimunLine = SupermarketDB.Instance.GetCashRegisters()[0].CustomersQueue.Count;
                cr = SupermarketDB.Instance.GetCashRegisters()[0];
                foreach (var cashReg in SupermarketDB.Instance.GetCashRegisters())
                {
                    if (cashReg.CustomersQueue.Count < MinimunLine && cashReg.IsStarted == true)
                    {
                        MinimunLine = cashReg.CustomersQueue.Count;
                        cr          = cashReg;
                    }
                }
            }

            return(cr);
        }
Ejemplo n.º 4
0
 public List <CashRegister> GetCashRegisters()
 {
     try
     {
         List <CashRegister> cashRegisters = cashregister_db.Db_Get_All_CashRegister();
         return(cashRegisters);
     }
     catch (Exception e)
     {
         // something went wrong connecting to the database, so we will add a fake Cashregister to the list to make sure the rest of the application continues working!
         List <CashRegister> cashRegister = new List <CashRegister>();
         CashRegister        a            = new CashRegister();
         a.StudentNummer = 999999;
         a.StudentNaam   = "Mr Test";
         a.DrankID       = 999;
         a.DrankNaam     = "slootwater";
         cashRegister.Add(a);
         CashRegister b = new CashRegister();
         b.StudentNummer = 999998;
         b.StudentNaam   = "Mrs Test";
         b.DrankID       = 998;
         b.DrankNaam     = "zeewater";
         cashRegister.Add(b);
         return(cashRegister);
         //throw new Exception("Someren couldn't connect to the database");
     }
 }
Ejemplo n.º 5
0
        public static void Process_MultipleItemTypesNoPromotions_CorrectReceiptEntriesMade()
        {
            // Arrange
            var register     = new CashRegister(Enumerable.Empty <IPromotion>());
            var groceryItems = new[]
            {
                new GroceryItem("Apples", 1.0m),
                new GroceryItem("Apples", 1.0m),
                new GroceryItem("Oranges", 2.0m),
                new GroceryItem("Oranges", 2.0m),
            };

            // Act
            var receiptEntries = register.Process(groceryItems).ToArray();

            // Assert
            Assert.That(receiptEntries.Count(), Is.EqualTo(2));

            //Test the receipt entry for apples
            var applesEntry = receiptEntries.First(e => e.ItemDescription == "Apples");

            Assert.That(applesEntry.Quantity, Is.EqualTo(2));
            Assert.That(applesEntry.UnitPrice, Is.EqualTo(1.0m));
            Assert.That(applesEntry.TotalPrice, Is.EqualTo(2.0m));
            Assert.That(applesEntry.Promotion, Is.False);

            //Test the receipt entry for oranges
            var orangesEntry = receiptEntries.First(e => e.ItemDescription == "Oranges");

            Assert.That(orangesEntry.Quantity, Is.EqualTo(2));
            Assert.That(orangesEntry.UnitPrice, Is.EqualTo(2.0m));
            Assert.That(orangesEntry.TotalPrice, Is.EqualTo(4.0m));
            Assert.That(orangesEntry.Promotion, Is.False);
        }
Ejemplo n.º 6
0
        public void CashRegister_DollarAmount_ReturnCorrectChange()
        {
            double input = 289.42;
            Dictionary <double, int> expected = new Dictionary <double, int>()
            {
                { 100, 2 },
                { 50, 1 },
                { 20, 1 },
                { 10, 1 },
                { 5, 1 },
                { 1, 4 },
                { .25, 1 },
                { .10, 1 },
                { .05, 1 },
                { .01, 2 }
            };
            var cashRegister = new CashRegister();

            var denominationArray = new List <double>()
            {
                100, 50, 20, 10, 5, 1, .25, .10, .05, .01
            };

            var output = cashRegister.GetChange(input, denominationArray);

            CollectionAssert.AreEqual(expected, output);
        }
Ejemplo n.º 7
0
        public CashBoxView(CashRegister cashRegister, int number, int x, int y)
        {
            this.cashRegister = cashRegister;

            CashRegisterName.AutoSize = true;
            CashRegisterName.Location = new System.Drawing.Point(x, y);
            CashRegisterName.Name     = "label" + number;
            CashRegisterName.Size     = new System.Drawing.Size(35, 13);
            CashRegisterName.TabIndex = number;
            CashRegisterName.Text     = cashRegister.ToString();

            Price.Location = new System.Drawing.Point(x + 70, y);
            Price.Name     = "numericUpDown" + number;
            Price.Size     = new System.Drawing.Size(120, 20);
            Price.TabIndex = number;
            Price.Maximum  = 1000000000000000;

            QueueLength.Location = new System.Drawing.Point(x + 250, y);
            QueueLength.Maximum  = cashRegister.MaxQueueLength;
            QueueLength.Name     = "progressBar" + number;
            QueueLength.Size     = new System.Drawing.Size(100, 23);
            QueueLength.TabIndex = number;
            QueueLength.Value    = 0;
            QueueLength.Minimum  = 0;
            QueueLength.Maximum  = 10;

            LeaveCustomersCount.AutoSize = true;
            LeaveCustomersCount.Location = new System.Drawing.Point(x + 400, y);
            LeaveCustomersCount.Name     = "label2" + number;
            LeaveCustomersCount.Size     = new System.Drawing.Size(35, 13);
            LeaveCustomersCount.TabIndex = number;
            LeaveCustomersCount.Text     = "";

            cashRegister.CheckClosed += CashRegister_CheckClosed;
        }
    public void OnInteract(InputAction.CallbackContext context)
    {
        if (!context.performed)
        {
            return;
        }

        switch (_currentPlayerMode)
        {
        case PlayerMode.Walking:
        {
            Interact();

            break;
        }

        case PlayerMode.Cashier:
        {
            _interactRegister  = null;
            _currentPlayerMode = PlayerMode.Walking;

            break;
        }

        case PlayerMode.Receiving:
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
    /************************************************/
    // Item interaction methods

    private void Interact()
    {
        string[]     tagsToScan          = { "Register" };
        GameObject[] excludedGameObjects = { gameObject };

        GameObject closestInteractable = EssentialFunctions.GetClosestInteractableInFOV(transform, pickupArea, pickupAngle, maxPickupDistance, tagsToScan, excludedGameObjects);

        if (!closestInteractable)
        {
            return;
        }

        switch (closestInteractable.tag)
        {
        case "Register":
        {
            _interactRegister = closestInteractable.GetComponent <CashRegister>();

            _currentPlayerMode = PlayerMode.Cashier;

            transform.position = _interactRegister.GetStandingPosition().position;
            transform.rotation = _interactRegister.GetStandingPosition().rotation;

            break;
        }
        }
    }
        public async Task <IResponse> SetCashRegisterAsync(CashRegister model)
        {
            var url      = $"{Controller}";
            var response = await WebService.PostAsync(url, model);

            return(response.ReadHttpContentAsync());
        }
Ejemplo n.º 11
0
 public Cashier(string firstName, string lastName, double salary) :
     base(firstName, lastName, salary)
 {
     cashRegisterCoin  = new CashRegisterCoin();
     cashRegisterPaper = new CashRegisterPaper();
     cashRegisterCard  = new CashRegisterCard();
 }
Ejemplo n.º 12
0
        protected override void PreProcess()
        {
            try
            {
                lastKeyPressed = DateTime.Now;
                KeyMap.Load();
                Debugger.Instance().AppendLine("Started Display: " + DateTime.Now.ToLongTimeString());

                DisplayAdapter.Instance();
                DisplayAdapter.Both.Show(PosMessage.PLEASE_WAIT);
                Application.DoEvents();
                Debugger.Instance().AppendLine("Finished Display" + DateTime.Now.ToLongTimeString());

                if (PosConfiguration.Get("BarcodeComPort") != "")
                {
                    ConnectBarcode();
                }

                //Console.CancelKeyPress += new ConsoleCancelEventHandler(pos_OnClosed);

                CashRegister.Instance();
                CashRegister.Printer.DateTimeChanged += new EventHandler(Printer_DateTimeChanged);

                Debugger.Instance().AppendLine("Started BackgroundWorker: " + DateTime.Now.ToLongTimeString());
                Thread thread = new Thread(new ThreadStart(BackgroundWorker.Start));
                thread.Name         = "BackgroundWorker";
                thread.IsBackground = true;
                thread.Priority     = ThreadPriority.BelowNormal;
                thread.Start();
            }
            catch (UnauthorizedAccessException ex)
            {
                throw ex;
            }
        }
    bool SetupCustomerQueue(int tries = 0)
    {
        if (tries >= maxTries)
        {
            return(false);
        }

        CashRegister foundRegister = stateMachine.mapManager.GetRandomCashRegister();

        if (foundRegister)
        {
            // Retry if the register queue is full
            if (foundRegister.IsFull())
            {
                SetupCustomerQueue(tries++);
            }

            // Get queuing position
            Vector3 customerPosition = foundRegister.AddToQueue(stateMachine.gameObject);

            // Attach queue change event to QueueState
            foundRegister.QueueChanged.AddListener(stateMachine.queuingState.QueueChanged);

            stateMachine.taskDestination         = foundRegister.transform;
            stateMachine.taskDestinationPosition = customerPosition;
        }

        return(true);
    }
Ejemplo n.º 14
0
 public static void StartShift(Employee emp)
 /// <summary>
 /// A method to start the epmloyee`s shift (starts the moment he calls this function - like swiping a card)
 /// start a shift means this.CurrentShift is updating
 /// The program picks the next available cash register which the employee will work on, and starts it
 /// if the last shift wasn`t ended (forgot to check out for example), he could not check in
 /// </summary>
 {
     if (emp.CurrentShift.Count == 1)
     {
         Console.WriteLine("Error! Your last shift was`nt ended. Please check out and try again");
     }
     else
     {
         if (IsEmployeeAllowedToWork(emp))
         {
             CashRegister CurrentCR = CashRegisterBL.GetClosedCashRegister();
             if (CurrentCR is null)
             {
                 Console.WriteLine($"No cash register available. You can`t start your shift, {emp.FullName}");
                 return;
             }
             emp.CurrentShift.Add(DateTime.Now);
             emp.CurrentCashRegister = CurrentCR.RegisterNumber;
             CashRegisterBL.StartTheCashRegister(emp, CurrentCR);
             Console.WriteLine($"Welcome, {emp.FullName}. Your cash register is {CurrentCR.RegisterNumber}");
             //CashRegister.OpenedCashRegisters(); // for debugging
         }
         else
         {
             Console.WriteLine("You cannot work like that. Go home! Your debt has grown by 40 ILS.");
             emp.Debt += 40;
         }
     }
 }
Ejemplo n.º 15
0
        public DocumentPaymentData(int DocumentID, WareDocument Document, CashRegister _CashRegister)
        {
            InitializeComponent();
            cashRegister       = _CashRegister;
            document           = Document;
            manager            = new ContextManager();
            documentSuma       = Document.DocumentSum;
            documentId         = DocumentID;
            PayDateDTP.Value   = DateTime.Now;
            DocumentSumaL.Text = Convert.ToString(documentSuma);
            CheckNumberTB.Text = document.Number;
            Fill();
            FillPaymentTypes();
            FillStructureObjects();

            ConfigurationParametersLogic config = new ConfigurationParametersLogic(manager);
            ConfigurationParameter       param0 = config.Get(ParametersLogic.Parameter.PAYMENTS_SHOW_CARD.ToString());

            if (param0 != null)
            {
                if (Helpers.ConfigDataTypeConverter.ConvertToBoolean(param0.Value) == true)
                {
                    tableLayoutPanel1.RowStyles[4].SizeType = SizeType.Absolute;

                    tableLayoutPanel1.RowStyles[4].Height = 0;
                }
            }
        }
Ejemplo n.º 16
0
        public void REQ_7_PayBillWithCheck()
        {
            var cashier      = _authentificationService.ConnectCashier("123456");
            var cashRegister = new CashRegister(cashier);

            var firstSelectedArticle = _articlesService.GetArticles("0102030405").First();

            cashRegister.AddArticle(firstSelectedArticle);

            var secondSelectedArticle = _articlesService.GetArticles("0203040506").First();

            cashRegister.AddArticle(secondSelectedArticle);

            var bracketTotalPrice = firstSelectedArticle.Price + secondSelectedArticle.Price;

            Assert.AreEqual(bracketTotalPrice, cashRegister.GetRemainsDependent());

            cashRegister.PayWithCheck(bracketTotalPrice);
            Assert.IsTrue(cashRegister.CanCompleteTransaction);
            Assert.AreEqual(0, cashRegister.GetRemainsDependent());
            Assert.AreEqual(1, cashRegister.Bracket.Transactions.Count());

            var firstTransaction = cashRegister.Bracket.Transactions.ElementAt(0);

            Assert.AreEqual(bracketTotalPrice, firstTransaction.Amount);
            Assert.AreEqual(TransactionType.Check, firstTransaction.Type);

            cashRegister.CompleteTransaction();
            Assert.IsNull(cashRegister.Bracket);
            Assert.IsNull(cashRegister.WebOrder);
        }
Ejemplo n.º 17
0
        public void Display_Bananes_Price()
        {
            var cashRegister = new CashRegister();
            var price        = cashRegister.Add("Bananes");

            Check.That(price).IsEqualTo(Prices.BananaPrice);
        }
Ejemplo n.º 18
0
        public void Display_Cerises_Price()
        {
            var cashRegister = new CashRegister();
            var price        = cashRegister.Add("Cerises");

            Check.That(price).IsEqualTo(Prices.CherryPrice);
        }
Ejemplo n.º 19
0
        public TestGreenCycle()
        {
            //Arrange
            ICashRegister cashRegister = new CashRegister();

            _cashier = new Cashier(cashRegister);
        }
Ejemplo n.º 20
0
 public void Initialize()
 {
     cashRegister = new CashRegister();
     priceQuery   = new PriceQuery(
         ItemReference.aReference().withItemCode("APPLE").withUnitPrice(1.20).build(),
         ItemReference.aReference().withItemCode("BANANA").withUnitPrice(1.90).build());
 }
Ejemplo n.º 21
0
        public void Display_Pommes_Price(string product)
        {
            var cashRegister = new CashRegister();
            var price        = cashRegister.Add(product);

            Check.That(price).IsEqualTo(Prices.ApplePrice);
        }
Ejemplo n.º 22
0
        private List <CashRegister> ReadTables(DataTable dataTable)
        {
            List <CashRegister> orders = new List <CashRegister>();

            foreach (DataRow dr in dataTable.Rows)
            {
                int     stid        = (int)dr["student_id"];
                int     drid        = (int)dr["drink_id"];
                int     quantityT   = (int)dr["Quantity"];
                Drink   drinkk      = drinkDAO.GetById(drid);
                decimal total_price = drinkk.Price * quantityT;

                CashRegister order = new CashRegister()
                {
                    order_id   = (int)dr["order_id"],
                    student    = studentDAO.GetById(stid),
                    drink      = drinkk,
                    quantity   = quantityT,
                    totalPrice = decimal.Parse(dr["total_price"].ToString()),
                    orderDate  = (DateTime)dr["OrderDate"]
                };

                orders.Add(order);
            }
            return(orders);
        }
Ejemplo n.º 23
0
        public void CashRegister(int[] num, int expected)
        {
            var CashRegisterInstance = new CashRegister();
            var actual = CashRegisterInstance.CashRegisterSum(num);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 24
0
 public void CashRegister()
 {
     var input = new[] { "15.94;16.00", "17;16", "35;35", "45;50",".01;.05" };
     var expected = new[] { "NICKEL,PENNY", "ERROR", "ZERO", "FIVE", "PENNY,PENNY,PENNY,PENNY" };
     var result = new CashRegister(input).Run();
     AssertExtensions.AreEqual(expected, result);
 }
Ejemplo n.º 25
0
        public DocumentsList(CashRegister _CashRegister)
        {
            InitializeComponent();
            CompasLogger.Add(String.Format("Start opening DocumentsList"), CompasLogger.Level.Info);
            cashRegister = _CashRegister;
            manager      = new ContextManager();
            bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("DocumentsList");

            if (allowed == true)
            {
                CompasLogger.Add(String.Format("FillDocumentFilter"), CompasLogger.Level.Info);
                documentFilterUC1.Fill();
                CompasLogger.Add(String.Format("FillUniversalFilter"), CompasLogger.Level.Info);
                universalFilter1.Fill();
                documentsLogic = new DocumentsLogic(manager);
                CompasLogger.Add(String.Format("Fill"), CompasLogger.Level.Info);
                Fill();
            }
            else
            {
                MessageBox.Show("Дія заборонена. Зверніться до адміністратора.");
                this.Close();
            }
            CompasLogger.Add(String.Format("End opening DocumentsList"), CompasLogger.Level.Info);
            //this.DataGV.CellPainting += new
            //     DataGridViewCellPaintingEventHandler(DataGV_CellPainting);
        }
Ejemplo n.º 26
0
        public void REQ_6_ResumeBracketMemento()
        {
            var cashier = _authentificationService.ConnectCashier("123456");

            Assert.IsNotNull(cashier);

            var cashRegister = new CashRegister(cashier);

            var articles = _articlesService.GetArticles("0102030405");

            Assert.IsTrue(articles.Count() > 0);

            var selectedArticle = articles.First();

            cashRegister.AddArticle(selectedArticle);

            var bracketMemento = cashRegister.MakeBracketMemento();

            _mementoService.SaveBracket(bracketMemento);
            Assert.IsNull(cashRegister.Bracket);

            var savedBracket = _mementoService.GetSavedBracket(bracketMemento.Id);

            Assert.AreEqual(0, _mementoService.SavedBrackets.Count());

            cashRegister.RestoreBracket(savedBracket);
            Assert.AreEqual(1, cashRegister.Bracket.Articles.Count());
            Assert.AreEqual(selectedArticle.Price, cashRegister.Bracket.GetTotalPrice());
        }
Ejemplo n.º 27
0
        private static IState ExitService(String password)
        {
            try
            {
                cr.Printer.ExitServiceMode(password);

                cr.SetPrinterPort(PosConfiguration.Get("PrinterComPort"));
                CashRegister.LoadCurrentSettings();
                cr.State = States.Start.Instance();
            }
            catch (CashierAutorizeException cae)
            {
                cr.State = AlertCashier.Instance(new Error(cae,
                                                           new StateInstance(Continue),
                                                           new StateInstance(Continue)));
                cr.Log.Error("CashierAutorizeException occured. {0}", cae.Message);
            }
            catch (CmdSequenceException ex)
            {
                cr.State = AlertCashier.Instance(new Error(ex,
                                                           new StateInstance(Continue),
                                                           new StateInstance(Continue)));
                cr.Log.Error("CmdSequenceException occured. {0}", ex.Message);
            }
            catch (SVCPasswordOrPointException ex)
            {
                cr.State = ConfirmCashier.Instance(new Error(ex,
                                                             new StateInstance(Continue),
                                                             new StateInstance(Continue)));
                cr.Log.Error("SVCPasswordOrPointException occured. {0}", ex);
            }

            return(cr.State);
        }
Ejemplo n.º 28
0
 public void Initialize()
 {
     priceQuery = new InmemoryCatalog(
         ItemReference.AReference().WithItemCode("APPLE").WithUnitPrice(1.20).Build(),
         ItemReference.AReference().WithItemCode("BANANA").WithUnitPrice(1.90).Build()
         );
     cashRegister = new CashRegister();
 }
Ejemplo n.º 29
0
 public void Create(CashRegister cash)
 {
     using (CoffeeStoreContext db = new CoffeeStoreContext())
     {
         db.CashRegisters.Add(cash);
         db.SaveChanges();
     }
 }
Ejemplo n.º 30
0
 void CashButtonClick(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order order)
     {
         CashRegister temp = new CashRegister(menu, order, receipt);
         menu.orderBorder.Child = temp;
     }
 }
Ejemplo n.º 31
0
        public void SumOfNumbers(int num1, int num2, int expected)
        {
            var summation = new CashRegister();

            var result = summation.SumOfNumbers(num1, num2);

            Assert.Equal(expected, result);
        }
 public ChangeStateCommand(CashRegister cashRegister)
 {
     _cashRegister = cashRegister;
 }
Ejemplo n.º 33
0
 public void CreateCashRegister()
 {
     _registerAllItemsOneDollar = new CashRegister(new AllItemsAreOneDollar());
 }
Ejemplo n.º 34
0
    static void Main(string[] args)
    {
        CashRegister cr = new CashRegister();

        string[] denoms = ("'PENNY': .01,'NICKEL': .05,'DIME': .10,'QUARTER': .25,'HALF DOLLAR': .50,'ONE':" +
                            "1.00,'TWO': 2.00,'FIVE': 5.00,'TEN': 10.00,'TWENTY': 20.00,'FIFTY': 50.00,'ONE HUNDRED': 100.00").Split(',');

        foreach (string s in denoms)
        {
            string[] split = s.Split(':');

            string name = split[0].Substring(1, split[0].Length - 2);
            decimal value = decimal.Parse(split[1].Trim());

            cr.AddCash(new Currency(name, value));
        }

        using (StreamReader reader = File.OpenText(args[0]))
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == null) continue;

                decimal[] values = line.Split(';').Select(x => decimal.Parse(x)).ToArray();

                Console.WriteLine(cr.GetChange(values));
            }
    }
 public CheckoutCommand(CashRegister cashRegister)
 {
     _cashRegister = cashRegister;
 }
 public EnterSkuCommand(CashRegister cashRegister)
 {
     _cashRegister = cashRegister;
 }
 public PayWithCashCommand(CashRegister cashRegister)
 {
     _cashRegister = cashRegister;
 }