Example #1
0
        /// <summary>
        /// Author:     Brian Sabotta
        /// Created:    10/30/2019
        /// Notes:      Checks parameters and starts running the cash register process.
        /// </summary>
        /// <param name="args">Collection of args passed in from command line.</param>
        public static void RunCashRegisterProcessor(string[] args)
        {
            try
            {
                //arg[0] - inputFile
                var inputFile = GetParameterByIndex(args, 0, "Input file");

                //Exit out if not provided
                if (string.IsNullOrEmpty(inputFile))
                {
                    return;
                }

                //arg[1] - outputFile
                var outputFile = GetParameterByIndex(args, 1, "Output file");

                //Exit out if not provided
                if (string.IsNullOrEmpty(outputFile))
                {
                    return;
                }

                //Call the processing method
                CashRegisterProcessor.ProcessData(inputFile, outputFile);
            }
            catch (Exception ex)
            {
                CashRegisterExceptions.HandleException(ex);
            }
        }
Example #2
0
        public void End2End_KnownProductBarcode_WillResultIn_ProductPrice()
        {
            var knownBarcode            = new Barcode();
            var knownProductPriceResult = new KnownProductPriceResult();

            var cashRegisterProcessorRendererTestDouble = new CashRegisterRendererTestDouble();
            var productPriceProviderTestDouble          = new ProductCatalogTestDouble(knownProductPriceResult);
            var cashRegisterProcessor = new CashRegisterProcessor(productPriceProviderTestDouble, cashRegisterProcessorRendererTestDouble);

            cashRegisterProcessor.OnBarcode(knownBarcode);

            Assert.Equal(knownProductPriceResult, cashRegisterProcessorRendererTestDouble.ResultToRender);
        }
Example #3
0
        public void End2End_UnknownProductBarcode_WillResultIn_UnknownProduct()
        {
            //discuss because behaviour of result known/unknow and renderer ????
            // smell => internals are external visibile, implementation detail


            var unknownBarcode            = new Barcode();
            var unknownProductPriceResult = new UnknownProductPriceResult();

            var cashRegisterProcessorRendererTestDouble = new CashRegisterRendererTestDouble();
            var productPriceProviderTestDouble          = new ProductCatalogTestDouble(unknownProductPriceResult);
            var cashRegisterProcessor = new CashRegisterProcessor(productPriceProviderTestDouble, cashRegisterProcessorRendererTestDouble);

            cashRegisterProcessor.OnBarcode(unknownBarcode);

            Assert.Equal(unknownProductPriceResult, cashRegisterProcessorRendererTestDouble.ResultToRender);
        }