public Dictionary <string, List <string> > Update(Stream file, bool sendEmails) { Dictionary <string, List <string> > parseErrors; List <BulkShippingUpdateDataTransferObject> items = GetOrdersFromFile(file, out parseErrors); if (parseErrors.Any()) { return(parseErrors); } Dictionary <string, List <string> > businessLogicErrors = _bulkShippingUpdateValidationService.ValidateBusinessLogic(items); if (businessLogicErrors.Any()) { return(businessLogicErrors); } int noOfUpdatedItems = _bulkShippingUpdateService.BulkShippingUpdateFromDTOs(items, sendEmails); return(new Dictionary <string, List <string> > { { "success", new List <string> { noOfUpdatedItems > 0 ? noOfUpdatedItems + (noOfUpdatedItems > 1 ? " items were" : " item was") + " successfully updated." : "No items were updated." } } }); }
public void BulkShippingUpdateValidationService_ValidateBusinessLogic_CallsAllIoCRegisteredRulesOnAllOrders() { var mockingKernel = new MockingKernel(); var validationRules = Enumerable.Range(1, 10).Select(i => A.Fake <IBulkShippingUpdateValidationRule>()).ToList(); validationRules.ForEach(rule => mockingKernel.Bind <IBulkShippingUpdateValidationRule>() .ToMethod(context => rule)); MrCMSKernel.OverrideKernel(mockingKernel); var items = Enumerable.Range(1, 10).Select(i => new BulkShippingUpdateDataTransferObject()).ToList(); _bulkShippingUpdateValidationService.ValidateBusinessLogic(items); validationRules.ForEach( rule => EnumerableHelper.ForEach(items, product => A.CallTo(() => rule.GetErrors(product)).MustHaveHappened())); }