Ejemplo n.º 1
0
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="orderInformation"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <Order> GetOrdersByOrderInformation(OrderInformation orderInformation)
        {
            try
            {
                //Resolve root dependencies and perform operations
                ISalesManagementService salesManagement = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>();

                return(salesManagement.FindOrdersByOrderInformation(orderInformation.CustomerId, orderInformation.DateTimeFrom, orderInformation.DateTimeTo));
            }
            catch (ArgumentException 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);
            }
        }
Ejemplo n.º 2
0
        public void FindOrdersByOrderInformation_Invoke_Test()
        {
            //Arrange
            ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>();
            int      customerId = 1;
            DateTime?from       = new DateTime(2008, 12, 1);
            DateTime?to         = new DateTime(2010, 1, 2);

            //Act
            List <Order> result  = orderService.FindOrdersByOrderInformation(customerId, from, to);
            List <Order> result2 = orderService.FindOrdersByOrderInformation(customerId, null, null);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count >= 1);

            Assert.IsNotNull(result2);
            Assert.IsTrue(result2.Count >= 1);
        }