コード例 #1
0
        public void ReadRootElementInfo_succeeds(RootElement rootElement, string versionText)
        {
            var elementInfo =
                new VersionedElementInfo(
                    rootElement,
                    BattleScribeVersion.Parse(versionText));

            using var stream = CreateEmptyElementStream(elementInfo);
            var result = DataVersionManagement.ReadRootElementInfo(stream);

            result.Should().Be(elementInfo);
        }
コード例 #2
0
 private void CheckBattleScribeVersionCompatibility(IWorkspace workspace)
 {
     foreach (var file in workspace.Datafiles)
     {
         var node = file.GetData();
         if (node is IRootNode rootNode && !string.IsNullOrWhiteSpace(rootNode.BattleScribeVersion))
         {
             var version             = BattleScribeVersion.Parse(rootNode.BattleScribeVersion);
             var maxSupportedVersion = node.Kind.ToRootElement().Info().CurrentVersion;
             if (version > maxSupportedVersion)
             {
                 Log.Warning(
                     "Processing {File} which has BattleScribeVersion higher than supported" +
                     " ({NodeVersion} > {SupportedVersion}).",
                     file, version, maxSupportedVersion);
             }
         }
     }
 }
コード例 #3
0
        public void Parse_throws_on_invalid_strings(string text)
        {
            Action act = () => BattleScribeVersion.Parse(text);

            act.Should().Throw <FormatException>("parsed text is invalid.");
        }
コード例 #4
0
        public void Parse_succeeds_on_valid_strings(string text, int major, int minor, string suffix = null)
        {
            var result = BattleScribeVersion.Parse(text);

            result.Should().Be(BattleScribeVersion.Create(major, minor, suffix));
        }
コード例 #5
0
        private static VersionedElementInfo CreateVersionedInfo(RootElement root, string versionText)
        {
            var version = versionText is null ? null : BattleScribeVersion.Parse(versionText);

            return(new VersionedElementInfo(root, version));
        }