public async Task ContentRulesFailed_DoesNotSaveToDraft() { var summary = new PrenotificationRulesSummary(); var message = new PerformPrenotificationContentValidation(summary, notificationId, new DataTable(), "Test", false); A.CallTo(() => mapper.Map(A <DataTable> .Ignored)).Returns(A.CollectionOfFake <PrenotificationMovement>(5).ToList()); A.CallTo(() => contentRule.GetResult(A <List <PrenotificationMovement> > .Ignored, notificationId)) .Returns(new PrenotificationContentRuleResult <PrenotificationContentRules>(PrenotificationContentRules.MissingData, MessageLevel.Error, "Missing data", 0)); var response = await handler.HandleAsync(message); Assert.False(response.IsContentRulesSuccess); A.CallTo(() => repository.AddPrenotifications(A <Guid> .Ignored, A <List <PrenotificationMovement> > .Ignored, "Test")).MustNotHaveHappened(); }
public async Task <PrenotificationRulesSummary> HandleAsync(PerformPrenotificationContentValidation message) { var result = message.RulesSummary; var movements = mapper.Map(message.DataTable); result.ContentRulesResults = await GetOrderedContentRules(movements, message.NotificationId); if (result.IsContentRulesSuccess) { result.ShipmentNumbers = movements.Where(m => m.ShipmentNumber.HasValue).Select(m => m.ShipmentNumber.Value); result.DraftBulkUploadId = await draftRepository.AddPrenotifications(message.NotificationId, movements, message.FileName); } return(result); }