// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using FakeItEasy; using Xunit; namespace Squidex.Domain.Apps.Entities.Backup { public class BackupCompatibilityTests { [Fact] public async Task Should_writer_version() { var writer = A.Fake(); await writer.WriteVersionAsync(); A.CallTo(() => writer.WriteJsonAsync(A._, A.That.Matches(x => x.Major == 5), default)) .MustHaveHappened(); } [Fact] public async Task Should_not_throw_exception_if_backup_has_correct_version() { var reader = A.Fake(); A.CallTo(() => reader.ReadJsonAsync(A._, default)) .Returns(new CompatibilityExtensions.FileVersion { Major = 5 }); await reader.CheckCompatibilityAsync(); } [Fact] public async Task Should_throw_exception_if_backup_has_wrong_version() { var reader = A.Fake(); A.CallTo(() => reader.ReadJsonAsync(A._, default)) .Returns(new CompatibilityExtensions.FileVersion { Major = 3 }); await Assert.ThrowsAsync(() => reader.CheckCompatibilityAsync()); } [Fact] public async Task Should_not_throw_exception_if_backup_has_no_version() { var reader = A.Fake(); A.CallTo(() => reader.ReadJsonAsync(A._, default)) .Throws(new FileNotFoundException()); await reader.CheckCompatibilityAsync(); } } }