Ejemplo n.º 1
0
        public async void Should_Create_Sales_With_Correct_Status(string cpf, string status)
        {
            var mockSalesRepo = new Mock <ISalesRepository>();
            var mockStrategy  = new Mock <ICashbackStrategy>();

            var service = new SalesService(mockSalesRepo.Object, mockStrategy.Object);

            var sales = new Sales
            {
                Cpf = cpf
            };

            await service.Create(sales);

            Assert.Equal(status, sales.Status);
        }
Ejemplo n.º 2
0
        public frmCharge(User user, Customer customer, Sale sale, decimal amount, decimal discount, decimal total)
        {
            InitializeComponent();

            this.User     = user;
            this.Customer = customer;
            sale.Amount   = amount;
            sale.Discount = discount;
            sale.Total    = total;
            this.Sale     = sale;

            this.salesService    = new SalesService();
            this.productsService = new ProductsService();

            this.Load += (s, e) =>
            {
                txtTicket.Text  = salesService.GetTicketNumber().ToString();
                txtDiscout.Text = this.Sale.Discount.ToString();
                txtTotal.Text   = this.Sale.Total.ToString();

                cmbUser.DataSource = new List <User> {
                    this.User
                };
                cmbUser.DisplayMember = "Username";
                cmbUser.ValueMember   = "Id";

                cmbCustomer.DataSource = new List <Customer> {
                    this.Customer
                };
                cmbCustomer.DisplayMember = "FullName";
                cmbCustomer.ValueMember   = "Id";

                txtCash.Focus();
            };

            btnCharge.Click += (s, e) =>
            {
                var currentSale = this.Sale;

                salesService.Create(currentSale, this.User, this.Customer);

                //
                //PrintTicket
                //
                PrintTicket(this.Sale);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            };

            txtCash.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    var currentSale = this.Sale;

                    salesService.Create(currentSale, this.User, this.Customer);

                    //
                    //PrintTicket
                    //
                    PrintTicket(this.Sale);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            };

            btnCancel.Click += (s, e) =>
            {
                this.DialogResult = System.Windows.Forms.DialogResult.No;
            };
        }