예제 #1
0
        public void Setup()
        {
            _sut   = _autoMocker.ClassUnderTest;
            _order = Builder <Video> .CreateNew()
                     .With(o => o.VideoType              = VideoType.LEARNING)
                     .With(o => o.VideoDetails           = Builder <VideoDetails> .CreateNew().Build())
                     .With(o => o.VideoDetails.VideoName = "Learning to Ski")
                     .With(o => o.OrderId = Guid.NewGuid())
                     .Build();

            _orderExecutionService = _autoMocker.Get <IOrderExecutionService>();
        }
예제 #2
0
        private static void ProcessAllOrders(IDictionary <Guid, IOrder> orders)
        {
            OrderProcessingService         orderProcessingService         = new OrderProcessingService();
            IOrderExecutionService         orderExecutionService          = new OrderExecutionService();
            MembershipProcessingStrategy   membershipProcessingStrategy   = new MembershipProcessingStrategy(orderExecutionService);
            ProductOrderProcessingStrategy productOrderProcessingStrategy = new ProductOrderProcessingStrategy(orderExecutionService);
            VideoRequestProcessingStrategy videoRquestProcessingStrategy  = new VideoRequestProcessingStrategy(orderExecutionService);

            Console.WriteLine("\n\t\t---------------------------------------------\n");
            Console.WriteLine("\n\t\t*********************************************\n");
            Console.WriteLine("\n\t\t* PROCESSING ALL THE PLACED ORDERS *\n");
            try
            {
                foreach (KeyValuePair <Guid, IOrder> kvp in orders)
                {
                    string name = kvp.Value.GetType().Name.ToUpper();
                    switch ((OrderType)Enum.Parse(typeof(OrderType), name))
                    {
                    case OrderType.MEMBERSHIP:
                        orderProcessingService.SetOrderProcessingStrategy(membershipProcessingStrategy);
                        orderProcessingService.ProcessOrder(kvp.Value);
                        break;

                    case OrderType.PRODUCT:
                        orderProcessingService.SetOrderProcessingStrategy(productOrderProcessingStrategy);
                        orderProcessingService.ProcessOrder(kvp.Value);
                        break;

                    case OrderType.VIDEO:
                        orderProcessingService.SetOrderProcessingStrategy(videoRquestProcessingStrategy);
                        orderProcessingService.ProcessOrder(kvp.Value);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("\n\t\t*********************************************\n");
            Console.WriteLine("\n\t\t---------------------------------------------\n");
            Console.WriteLine("\n\t\t* ALL ORDERS HAS BEEN PROCESSED *\n");
        }