Exemplo n.º 1
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);

            entryFromRepo.Description.English.Should().Be("Updated", "Description was updated");

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

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

            entryFromRepo = _repository.Load <Album>(result.Id);
            entryFromRepo.Description.English.Should().Be("Original", "Description was restored");

            var lastVersion = entryFromRepo.ArchivedVersionsManager.GetLatestVersion();

            lastVersion.Should().NotBeNull("Last version is available");
            lastVersion.Reason.Should().Be(AlbumArchiveReason.Reverted, "Last version archive reason");
            lastVersion.Diff.Cover.IsChanged.Should().BeFalse("Picture was not changed");
        }
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);

            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");
        }