public void LibraryItemFilePathChangeWorks() { LibraryItem item = new LibraryItem(_eventFactory, "foo/bar.mp3"); item.FilePath = item.FilePath + "x"; Assert.Equal(2, item.GetUncommittedEvents().Count()); ItemCanBeRebuiltFromUncommittedEvents(item); }
public void NoEventsGeneratedIfDataHasNotChanged() { LibraryItem item = new LibraryItem(_eventFactory, "foo/bar.mp3"); item.Commit(); item.Album = item.Album; item.Artist = item.Artist; item.FilePath = item.FilePath; item.Name = item.Name; Assert.Empty(item.GetUncommittedEvents()); }
private void ItemCanBeRebuiltFromUncommittedEvents(LibraryItem item) { LibraryItem itemFromEvents = new LibraryItem(_eventFactory); IEnumerable <IEvent> events = item.GetUncommittedEvents(); InMemoryJsonEventRepository repo = new InMemoryJsonEventRepository(); foreach (IEvent @event in events) { repo.Save(@event); } itemFromEvents.Apply(repo.GetEvents(item.AggregateId)); Assert.Equal(item, itemFromEvents); }