public void ThenTheFollowingSalesRecordShouldBeRecorded(Table table)
        {
            var saleRecord = table.CreateInstance <CreateSaleRecordModel>();

            var database = _context.DatabaseService;

            var sale = database.Sales.Last();

            var lookup = new DatabaseLookup(database);

            var customerId = lookup.GetCustomerId(saleRecord.Customer);

            var employeeId = lookup.GetEmployeeId(saleRecord.Employee);

            var productId = lookup.GetProductIdByName(saleRecord.Product);

            Assert.That(
                sale.Date,
                Is.EqualTo(saleRecord.Date));

            Assert.That(
                sale.Customer.Id,
                Is.EqualTo(customerId));

            Assert.That(
                sale.Employee.Id,
                Is.EqualTo(employeeId));

            Assert.That(
                sale.Product.Id,
                Is.EqualTo(productId));

            Assert.That(
                sale.UnitPrice,
                Is.EqualTo(saleRecord.UnitPrice));

            Assert.That(
                sale.Quantity,
                Is.EqualTo(saleRecord.Quantity));

            Assert.That(
                sale.TotalPrice,
                Is.EqualTo(saleRecord.TotalPrice));
        }
예제 #2
0
        public void GivenTheFollowingSaleInfo(Table table)
        {
            var saleInfo = table.CreateInstance <CreateSaleInfoModel>();

            _context.Mocker.GetMock <IDateService>()
            .Setup(p => p.GetDate())
            .Returns(saleInfo.Date);

            var mockDatabase = _context.Mocker.GetMock <IDatabaseContext>();

            var lookup = new DatabaseLookup(mockDatabase.Object);

            _model = new CreateSaleModel
            {
                CustomerId = lookup.GetCustomerId(saleInfo.Customer),
                EmployeeId = lookup.GetEmployeeId(saleInfo.Employee),
                ProductId  = lookup.GetProductIdByName(saleInfo.Product),
                Quantity   = saleInfo.Quantity
            };
        }