public void When_saving_media_item_should_write_file_to_library_directory()
        {
            var persistence = new Mock<IPersistence>();
            var persister = new MediaItemPersister(persistence.Object);

            var mediaItem = new MediaItem { Id = "test1", Name = "test-1", IsAvailable = true, DataStream = () => new MemoryStream() };
            persister.Save(mediaItem);

            persistence.Verify(p => p.WriteTextFile("library", "test1", It.Is<string>(xml => MediaItemXml(mediaItem, xml))));
            persistence.Verify(p => p.WriteBinaryFile("library.data", "test1", It.IsAny<Stream>()));
        }
        public void Given_media_binary_already_exists_when_saving_media_item_should_not_write_file_to_library_directory()
        {
            var persistence = new Mock<IPersistence>(MockBehavior.Strict);
            var persister = new MediaItemPersister(persistence.Object);

            persistence.Setup(p => p.Filenames("library.data")).Returns(new[] { "test1" });
            persistence.Setup(p => p.WriteTextFile(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()));

            var mediaItem = new MediaItem { Id = "test1", Name = "test-1", IsAvailable = true, DataStream = () => new MemoryStream() };
            persister.Save(mediaItem);

            persistence.Verify(p => p.WriteTextFile("library", "test1", It.Is<string>(xml => MediaItemXml(mediaItem, xml))));
        }