/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/> /// </summary> /// <param name="order"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param> public void ChangeOrder(Order order) { try { //Resolve root dependencies and perform operations ISalesManagementService salesManagement = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>(); salesManagement.ChangeOrder(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); } }
public void ChangeOrder_Invoke_NullItemThrowNullArgumentException_Test() { //Arrange ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>(); //Act orderService.ChangeOrder(null); }
public void ChangeOrder_Invoke_Test() { //Arrange ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve <ISalesManagementService>(); string shippingName = "Book"; string newShippingCity = "Pozuelo"; //Act List <Order> orders = orderService.FindOrdersByShippingData(shippingName, null, null, null); Order order = orders.First(); order.ShippingCity = newShippingCity; orderService.ChangeOrder(order); orders = orderService.FindOrdersByShippingData(shippingName, null, null, null); //Assert Assert.IsNotNull(orders); Assert.IsTrue(orders.Count > 0); Assert.IsTrue(orders.First().ShippingCity == newShippingCity); }