protected override void Context() { base.Context(); _historyItemDTO1 = new HistoryItemDTO(A.Fake <ICommand>()) { Id = "toto" }; _historyItemDTO2 = new HistoryItemDTO(A.Fake <ICommand>()) { Id = "tata" }; _historyItemDTO3 = new HistoryItemDTO(A.Fake <ICommand>()) { Id = "titi" }; _historyItemDTO4 = new HistoryItemDTO(A.Fake <ICommand>()) { Id = "tutu" }; _historyItemDTO2.AddSubHistory(_historyItemDTO3); _historyItemDTO3.AddSubHistory(_historyItemDTO4); _underlyingList.Add(_historyItemDTO1); _underlyingList.Add(_historyItemDTO2); }
private IHistoryItemDTO mapFrom(IHistoryItem historyItem, ICommand command) { if (!command.Visible) { return(new NullHistoryItemDTO()); } var historyDto = new HistoryItemDTO(command); historyDto.Id = Guid.NewGuid().ToString(); historyDto.State = historyItem.State; historyDto.User = historyItem.User; historyDto.DateTime = historyItem.DateTime; historyDto.ObjectType = command.ObjectType; historyDto.CommandType = command.CommandType; historyDto.Description = command.Description; historyDto.Loaded = command.Loaded; historyDto.ExtendedDescription = command.ExtendedDescription; foreach (var dynamicColumn in _historyBrowserConfiguration.AllDynamicColumnNames) { historyDto.ExtendedProperties.Add(command.ExtendedPropertyValueFor(dynamicColumn)); } //Add sub commands in the reverse order to display them in the chronological order var macroCommand = command as IMacroCommand; if (macroCommand == null) { return(historyDto); } macroCommand.All().Reverse().Where(subCommand => subCommand.Visible) .Each(subCommand => historyDto.AddSubHistory(mapFrom(historyItem, subCommand))); return(historyDto); }