Exemple #1
0
        public void Revert()
        {
            // Arrange
            artist.Description.English = "Original";
            var oldVer   = repository.HandleTransaction(ctx => queries.Archive(ctx, artist, ArtistArchiveReason.PropertiesUpdated));
            var contract = new ArtistForEditContract(artist, ContentLanguagePreference.English);

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

            var entryFromRepo = repository.Load <Artist>(artist.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 <Artist>(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(ArtistArchiveReason.Reverted, lastVersion.Reason, "Last version archive reason");
            Assert.IsFalse(lastVersion.Diff.Picture, "Picture was not changed");
        }