public void shouldDisplayErrorWhenBarcodeIsEmpty()
        {
            var productCatalog = Substitute.For<ProductCatalog>();

            var display = Substitute.For<Display>();
            var sale = new Sale(display, productCatalog);

            sale.onBarcodeReceived("");
            display.Received().show("Error: Barcode is empty, fix your scanner please.");
        }
        public void shouldDisplayPriceForProduct()
        {
            var productCatalog = Substitute.For<ProductCatalog>();
            var display = Substitute.For<Display>();
            productCatalog.lookupPriceForBarcode("1212").Returns(123.5f);
            var sale = new Sale(display, productCatalog);

            sale.onBarcodeReceived("1212");

            display.Received().show("123.50 kr");
        }
        public void shouldDisplayErrorWhenNoProduct()
        {
            var productCatalog = Substitute.For<ProductCatalog>();
            productCatalog.WhenForAnyArgs(catalog => catalog.lookupPriceForBarcode("")).Do(
                info => { throw new ProductNotFoundException(); });
            var display = Substitute.For<Display>();
            var sale = new Sale(display, productCatalog);

            sale.onBarcodeReceived("iPhone");
            display.Received().show("Error: No such product");
        }
        public void shouldDisplayErrorWhenTheCatalogMakesBOOM()
        {
            var productCatalog = Substitute.For<ProductCatalog>();

            productCatalog.WhenForAnyArgs(catalog => catalog.lookupPriceForBarcode("")).Do(
                info => { throw new NullReferenceException(); });

            var display = Substitute.For<Display>();
            var sale = new Sale(display, productCatalog);

            sale.onBarcodeReceived("iPad");

            display.Received().show("Error: Something went real bad with the product catalog.");
        }
        public void shouldDisplayErrorWhenTheDisplayMakesBOOM()
        {
            var productCatalog = Substitute.For<ProductCatalog>();
            productCatalog.lookupPriceForBarcode("iPad").Returns(122);
            var display = Substitute.For<Display>();
            display.WhenForAnyArgs(catalog => catalog.show("")).Do(
                info => { throw new NullReferenceException(); });

            var sale = new Sale(display, productCatalog);

            try
            {
                sale.onBarcodeReceived("iPad");
                Assert.Fail("the driver is broken why no exception");
            }
            catch (DisplayDriverError)
            {
            }
        }
        public void shouldDisplayPriceWithPrecisionOfTwo()
        {
            var productCatalog = Substitute.For<ProductCatalog>();

            productCatalog.lookupPriceForBarcode("iPad").Returns(122);

            var display = Substitute.For<Display>();
            var sale = new Sale(display, productCatalog);

            sale.onBarcodeReceived("iPad");
            display.Received().show("122.00 kr");
        }