示例#1
0
        public void LibraryItemFilePathChangeWorks()
        {
            LibraryItem item = new LibraryItem(_eventFactory, "foo/bar.mp3");

            item.FilePath = item.FilePath + "x";
            Assert.Equal(2, item.GetUncommittedEvents().Count());
            ItemCanBeRebuiltFromUncommittedEvents(item);
        }
示例#2
0
        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());
        }
示例#3
0
        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);
        }