Exemplo n.º 1
0
        public void Update_Names()
        {
            var contract = new AlbumForEditContract(album, ContentLanguagePreference.English);

            contract.Names.First().Value = "Replaced name";
            contract.UpdateNotes = "Updated album";

            contract = CallUpdate(contract);
            Assert.AreEqual(album.Id, contract.Id, "Update album Id as expected");

            var albumFromRepo = repository.Load(contract.Id);

            Assert.AreEqual("Replaced name", albumFromRepo.DefaultName);
            Assert.AreEqual(1, albumFromRepo.Version, "Version");
            Assert.AreEqual(0, albumFromRepo.AllArtists.Count, "No artists");
            Assert.AreEqual(0, albumFromRepo.AllSongs.Count, "No songs");

            var archivedVersion = repository.List <ArchivedAlbumVersion>().FirstOrDefault();

            Assert.IsNotNull(archivedVersion, "Archived version was created");
            Assert.AreEqual(album, archivedVersion.Album, "Archived version album");
            Assert.AreEqual(AlbumArchiveReason.PropertiesUpdated, archivedVersion.Reason, "Archived version reason");
            Assert.AreEqual(AlbumEditableFields.Names, archivedVersion.Diff.ChangedFields, "Changed fields");

            var activityEntry = repository.List <ActivityEntry>().FirstOrDefault();

            Assert.IsNotNull(activityEntry, "Activity entry was created");
            Assert.AreEqual(album, activityEntry.EntryBase, "Activity entry's entry");
            Assert.AreEqual(EntryEditEvent.Updated, activityEntry.EditEvent, "Activity entry event type");
        }
Exemplo n.º 2
0
        public void Revert()
        {
            // Arrange
            album.Description.English = "Original";
            var oldVer   = repository.HandleTransaction(ctx => queries.Archive(ctx, album, AlbumArchiveReason.PropertiesUpdated));
            var contract = new AlbumForEditContract(album, ContentLanguagePreference.English, new InMemoryImagePersister());

            contract.Description.English = "Updated";
            CallUpdate(contract);

            var entryFromRepo = repository.Load <Album>(album.Id);

            Assert.AreEqual("Updated", entryFromRepo.Description.English, "Description was updated");

            // Act
            var result = queries.RevertToVersion(oldVer.Id);

            // Assert
            Assert.AreEqual(0, result.Warnings.Length, "Number of warnings");

            entryFromRepo = repository.Load <Album>(result.Id);
            Assert.AreEqual("Original", entryFromRepo.Description.English, "Description was restored");

            var lastVersion = entryFromRepo.ArchivedVersionsManager.GetLatestVersion();

            Assert.IsNotNull(lastVersion, "Last version is available");
            Assert.AreEqual(AlbumArchiveReason.Reverted, lastVersion.Reason, "Last version archive reason");
            Assert.IsFalse(lastVersion.Diff.Cover.IsChanged, "Picture was not changed");
        }