public void ItemWithRegisteredBarcodeIsStoredInsideScannedItems(string barcode)
        {
            // Arrange
            var registry = new InMemoryItemRegistry();
            var sut      = new PointOfSaleServiceBuilder()
                           .WithQuery(registry)
                           .WithGenerator(new Mock <TransactionIdGenerator>().Object)
                           .Build();
            var expected = registry.Read(barcode);

            // Act
            sut.OnBarcodeScan(barcode);

            // Assert
            sut.ScannedItems.Should().Contain(expected);
        }
예제 #2
0
        public void ItShouldBeAbleToReturnAllItemsStored()
        {
            // Arrange
            var registry = new InMemoryItemRegistry();
            var expected = new List <Item>();

            expected.Add(new Item("123456", "Bowl", 12.50));
            expected.Add(new Item("900000", "Phone", 7.50));
            expected.Add(new Item("456789", "Crab", 24.50));
            expected.Add(new Item("345670", "Plunger", 6.50));
            expected.Add(new Item("789010", "Fish", 10.25));

            // Act
            var actual = registry.GetAvailableItems();

            // Assert
            actual.ShouldBeEquivalentTo(expected);
        }
        public void ScannedItemIsDisplayed()
        {
            // Arrange
            var    registry = new InMemoryItemRegistry();
            var    sut      = new Mock <Display>();
            string barcode  = "123456";
            var    sale     = new PointOfSaleServiceBuilder()
                              .WithQuery(new InMemoryItemRegistry())
                              .WithGenerator(new Mock <TransactionIdGenerator>().Object)
                              .WithDisplay(sut.Object)
                              .Build();
            var expected = new ScannedBarcodeEventArgs(registry.Read(barcode));

            // Act
            sale.OnBarcodeScan(barcode);

            // Assert
            sut.Verify(s => s.BarcodeHandler(sale, expected));
        }