public async Task ContentRulesFailed_DoesNotSaveToDraft()
        {
            var notificationId = Guid.NewGuid();
            var summary        = new ReceiptRecoveryRulesSummary();
            var message        = new PerformReceiptRecoveryContentValidation(summary, notificationId, new DataTable(), "Test", false);

            A.CallTo(() => mapper.Map(A <DataTable> .Ignored)).Returns(A.CollectionOfFake <ReceiptRecoveryMovement>(5).ToList());
            A.CallTo(() => contentRule.GetResult(A <List <ReceiptRecoveryMovement> > .Ignored, notificationId))
            .Returns(new ReceiptRecoveryContentRuleResult <ReceiptRecoveryContentRules>(ReceiptRecoveryContentRules.MaximumShipments,
                                                                                        MessageLevel.Error, "Missing data", 0));

            var response = await handler.HandleAsync(message);

            Assert.False(response.IsContentRulesSuccess);
            A.CallTo(() => repository.AddReceiptRecovery(A <Guid> .Ignored, A <List <ReceiptRecoveryMovement> > .Ignored, "Test")).MustNotHaveHappened();
        }
コード例 #2
0
        public async Task <ReceiptRecoveryRulesSummary> HandleAsync(PerformReceiptRecoveryContentValidation message)
        {
            var result = message.BulkMovementRulesSummary;

            var movements = mapper.Map(message.DataTable);

            result.ContentRulesResults = await GetOrderedContentRules(movements, message.NotificationId);

            result.ShipmentNumbers =
                movements.Where(m => m.ShipmentNumber.HasValue).Select(m => m.ShipmentNumber.Value);

            if (result.IsContentRulesSuccess)
            {
                result.DraftBulkUploadId = await repository.AddReceiptRecovery(message.NotificationId, movements, message.FileName);
            }

            return(result);
        }