示例#1
0
        public async Task Revert()
        {
            // Arrange
            _artist.Description.English = "Original";
            var oldVer = await _repository.HandleTransactionAsync(ctx => _queries.ArchiveAsync(ctx, _artist, ArtistArchiveReason.PropertiesUpdated));

            var contract = new ArtistForEditContract(_artist, ContentLanguagePreference.English, new InMemoryImagePersister());

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

            var entryFromRepo = _repository.Load <Artist>(_artist.Id);

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

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

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

            entryFromRepo = _repository.Load <Artist>(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(ArtistArchiveReason.Reverted, "Last version archive reason");
            lastVersion.Diff.Picture.IsChanged.Should().BeFalse("Picture was not changed");
        }