public void WhenChangeItemsIsInvoked_ThenGenerateOrderChagedEvent() { //arrange var newItems = new List <OrderDetailDTO> { new OrderDetailDTO { ItemName = "Cake", Quntity = 1, Price = 25 } }; var changeItems = new List <OrderDetailDTO> { }; var removeItems = new List <OrderDetailDTO> { }; Order target = new Order(); OrderChangedEvent expect = new OrderChangedEvent(target.Id, 1, new[] { new OrderDetailEventModel { ItemName = "Cake", Quntaty = 1, Price = 25 } } ); //act target.ChangeItems(changeItems, newItems, removeItems); var actual = target.IterateEvent().First() as OrderChangedEvent; //assert actual.Should().Equals(expect); }
public void OnNext(OrderChangedEvent changedEvent) { if (changedEvent.ChangeState == EntryState.Added) { var oldUsages = new List <PromotionUsage>(); var newUsages = GetCouponUsages(changedEvent.ModifiedOrder.Id, changedEvent.ModifiedOrder); RecordUsages(changedEvent.ModifiedOrder.Id, oldUsages, newUsages); } }
public virtual async Task Handle(OrderChangedEvent message) { var operationLogs = new List <OperationLog>(); foreach (var changedEntry in message.ChangedEntries) { operationLogs.AddRange(await GetChangedEntryOperationLogsAsync(changedEntry)); } if (!operationLogs.IsNullOrEmpty()) { _changeLogService.SaveChanges(operationLogs.ToArray()); } }