/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/> /// </summary> /// <param name="pagedCriteria"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns> public List <Order> GetPagedOrders(PagedCriteria pagedCriteria) { try { //Resolve root dependencies and perform operations ISalesManagementService salesManagement = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>(); return(salesManagement.FindPagedOrders(pagedCriteria.PageIndex, pagedCriteria.PageCount)); } 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); } }
public void FindPagedOrders_Invoke_NullPageCountThrowArgumentException_Test() { //Arrange ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>(); //Act List <Order> orders = orderService.FindPagedOrders(0, 0); }
public void FindPagedOrders_Invoke_Test() { //Arrange ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>(); //act List <Order> orders = orderService.FindPagedOrders(0, 1); //assert Assert.IsNotNull(orders); Assert.IsTrue(orders.Count == 1); }