Пример #1
0
        public void AddOrder_Invoke_Test()
        {
            //Arrange
            using (ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>())
            {
                string shippingZip = "9999";
                Order  order       = new Order()
                {
                    OrderDate       = DateTime.Now,
                    DeliveryDate    = DateTime.Now.AddDays(1),
                    ShippingAddress = "shipping address",
                    ShippingCity    = "Shipping City",
                    ShippingName    = "Shipping Name",
                    ShippingZip     = shippingZip,
                    CustomerId      = 1
                };

                //act
                orderService.AddOrder(order);
                List <Order> products = orderService.FindOrdersByShippingData(null, null, null, shippingZip);

                //assert
                Assert.IsNotNull(products);
                Assert.IsTrue(products.Count == 1);
            }
        }
Пример #2
0
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="order"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        public void AddOrder(Order order)
        {
            try
            {
                //Resolve root dependencies and perform operations
                ISalesManagementService salesManagement = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>();
                salesManagement.AddOrder(order);
            }
            catch (ArgumentNullException ex)
            {
                //trace data for internal health system and return specific FaultException here!
                //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!)

                //log exception for manage health system
                ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>();
                traceManager.TraceError(ex.Message);

                //propagate exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
Пример #3
0
        public void AddOrder_Invoke_NullItemThrowNewArgumentNullException_Test()
        {
            //Arrange
            ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>();

            orderService.AddOrder(null);
        }