コード例 #1
0
        public void NotSameObjectTest()
        {
            HeroesDataVersion heroesVersion = new HeroesDataVersion(1, 1, 1, 11111, true);

            Assert.AreNotEqual(new List <string>()
            {
                "asdf"
            }, heroesVersion);
        }
コード例 #2
0
        public void EqualsMethodTest()
        {
            Assert.IsFalse(new HeroesDataVersion(2, 45, 124, 154787, false).Equals((int?)null));
            Assert.IsFalse(new HeroesDataVersion(2, 45, 124, 154787, false).Equals(5));

            HeroesDataVersion version = new HeroesDataVersion(2, 45, 124, 154787, false);

            Assert.IsTrue(version.Equals(obj: version));
        }
コード例 #3
0
        public void VersionMinimumTest(int major, int minor, int revision, int build, bool isPtr = false)
        {
            HeroesDataVersion heroesVersion = new HeroesDataVersion(major, minor, revision, build, isPtr);

            Assert.AreEqual(0, heroesVersion.Major);
            Assert.AreEqual(0, heroesVersion.Minor);
            Assert.AreEqual(0, heroesVersion.Revision);
            Assert.AreEqual(0, heroesVersion.Build);
        }
コード例 #4
0
    /// <summary>
    /// Updates the gamestrings of <paramref name="hero"/>.
    /// </summary>
    /// <param name="hero">The data who's gamestrings will be updated.</param>
    /// <param name="version">The version directory to load the gamestrings from.</param>
    /// <param name="localization">The <see cref="Localization"/> of the gamestrings.</param>
    /// <exception cref="ArgumentNullException"><paramref name="hero"/> is null.</exception>
    /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception>
    public void UpdateGameString(Hero hero, HeroesDataVersion version, Localization localization)
    {
        ArgumentNullException.ThrowIfNull(hero, nameof(hero));
        ArgumentNullException.ThrowIfNull(version, nameof(version));

        (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _heroFileTemplateName, false, true);

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath);

        hero.UpdateGameStrings(gameStringDocument);
    }
コード例 #5
0
    /// <summary>
    /// Updates the gamestrings of <paramref name="emoticonPack"/>.
    /// </summary>
    /// <param name="emoticonPack">The data who's gamestrings will be updated.</param>
    /// <param name="version">The version directory to load the gamestrings from.</param>
    /// <param name="localization">The <see cref="Localization"/> of the gamestrings.</param>
    /// <exception cref="ArgumentNullException"><paramref name="emoticonPack"/> is null.</exception>
    /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception>
    public void UpdateGameString(EmoticonPack emoticonPack, HeroesDataVersion version, Localization localization)
    {
        ArgumentNullException.ThrowIfNull(emoticonPack, nameof(emoticonPack));
        ArgumentNullException.ThrowIfNull(version, nameof(version));

        (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _emoticonPackFileTemplateName, false, true);

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath);

        emoticonPack.UpdateGameStrings(gameStringDocument);
    }
コード例 #6
0
    /// <summary>
    /// Updates the gamestrings of <paramref name="rewardPortrait"/>.
    /// </summary>
    /// <param name="rewardPortrait">The data who's gamestrings will be updated.</param>
    /// <param name="version">The version directory to load the gamestrings from.</param>
    /// <param name="localization">The <see cref="Localization"/> of the gamestrings.</param>
    /// <exception cref="ArgumentNullException"><paramref name="rewardPortrait"/> is null.</exception>
    /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception>
    public void UpdateGameString(RewardPortrait rewardPortrait, HeroesDataVersion version, Localization localization)
    {
        ArgumentNullException.ThrowIfNull(rewardPortrait, nameof(rewardPortrait));
        ArgumentNullException.ThrowIfNull(version, nameof(version));

        (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _rewardPortraitFileTemplateName, false, true);

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath);

        rewardPortrait.UpdateGameStrings(gameStringDocument);
    }
コード例 #7
0
    /// <summary>
    /// Updates the gamestrings of <paramref name="announcer"/>.
    /// </summary>
    /// <param name="announcer">The data who's gamestrings will be updated.</param>
    /// <param name="version">The version directory to load the gamestrings from.</param>
    /// <param name="localization">The <see cref="Localization"/> of the gamestrings.</param>
    /// <exception cref="ArgumentNullException"><paramref name="announcer"/> is null.</exception>
    /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception>
    public void UpdateGameString(Announcer announcer, HeroesDataVersion version, Localization localization)
    {
        ArgumentNullException.ThrowIfNull(announcer, nameof(announcer));
        ArgumentNullException.ThrowIfNull(version, nameof(version));

        (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _announcerFileTemplateName, false, true);

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath);

        announcer.UpdateGameStrings(gameStringDocument);
    }
コード例 #8
0
    /// <summary>
    /// Updates the gamestrings of <paramref name="matchAward"/>.
    /// </summary>
    /// <param name="matchAward">The data who's gamestrings will be updated.</param>
    /// <param name="version">The version directory to load the gamestrings from.</param>
    /// <param name="localization">The <see cref="Localization"/> of the gamestrings.</param>
    /// <exception cref="ArgumentNullException"><paramref name="matchAward"/> is null.</exception>
    /// <exception cref="ArgumentNullException"><paramref name="version"/> is null.</exception>
    public void UpdateGameString(MatchAward matchAward, HeroesDataVersion version, Localization localization)
    {
        ArgumentNullException.ThrowIfNull(matchAward, nameof(matchAward));
        ArgumentNullException.ThrowIfNull(version, nameof(version));

        (_, string gameStringPath) = GetDataAndGameStringPaths(version, true, localization, _matchAwardFileTemplateName, false, true);

        using GameStringDocument gameStringDocument = GameStringDocument.Parse(gameStringPath);

        matchAward.UpdateGameStrings(gameStringDocument);
    }
コード例 #9
0
        public void CompareToMethodTest()
        {
            Assert.AreEqual(1, new HeroesDataVersion(2, 45, 124, 154787, false).CompareTo((int?)null));
            Assert.ThrowsException <ArgumentException>(() =>
            {
                new HeroesDataVersion(2, 45, 124, 154787, false).CompareTo(5);
            });

            Assert.AreEqual(0, new HeroesDataVersion(2, 45, 124, 154787, false).CompareTo(obj: new HeroesDataVersion(2, 45, 124, 154787, false)));

            HeroesDataVersion version = new HeroesDataVersion(2, 45, 124, 154787, false);

            Assert.AreEqual(0, version.CompareTo(obj: version));
        }
コード例 #10
0
    public void TryParseSuccessTest(string value, int major, int minor, int revision, int build, bool isPtr)
    {
        Assert.IsTrue(HeroesDataVersion.TryParse(value, out HeroesDataVersion? result));
        Assert.AreEqual(major, result !.Major);
        Assert.AreEqual(minor, result.Minor);
        Assert.AreEqual(revision, result.Revision);
        Assert.AreEqual(build, result.Build);
        Assert.AreEqual(isPtr, result.IsPtr);

        Assert.IsTrue(HeroesDataVersion.TryParse(value.AsSpan(), out HeroesDataVersion? resultSpan));
        Assert.AreEqual(major, resultSpan !.Major);
        Assert.AreEqual(minor, resultSpan.Minor);
        Assert.AreEqual(revision, resultSpan.Revision);
        Assert.AreEqual(build, resultSpan.Build);
        Assert.AreEqual(isPtr, resultSpan.IsPtr);
    }
コード例 #11
0
    public void ParseExceptionsTest()
    {
        Assert.ThrowsException <FormatException>(() =>
        {
            HeroesDataVersion.Parse(string.Empty);
        });
        Assert.ThrowsException <ArgumentNullException>(() =>
        {
            HeroesDataVersion.Parse(null !);
        });

        Assert.ThrowsException <ArgumentNullException>(() =>
        {
            string?value = null;
            HeroesDataVersion.Parse(value.AsSpan());
        });
    }
コード例 #12
0
    public void ParseSuccessTest(string value, int major, int minor, int revision, int build, bool isPtr)
    {
        HeroesDataVersion version = HeroesDataVersion.Parse(value);

        Assert.AreEqual(major, version !.Major);
        Assert.AreEqual(minor, version.Minor);
        Assert.AreEqual(revision, version.Revision);
        Assert.AreEqual(build, version.Build);
        Assert.AreEqual(isPtr, version.IsPtr);

        HeroesDataVersion versionSpan = HeroesDataVersion.Parse(value.AsSpan());

        Assert.AreEqual(major, versionSpan !.Major);
        Assert.AreEqual(minor, versionSpan.Minor);
        Assert.AreEqual(revision, versionSpan.Revision);
        Assert.AreEqual(build, versionSpan.Build);
        Assert.AreEqual(isPtr, versionSpan.IsPtr);
    }
コード例 #13
0
 public void ParseFailTest(string value)
 {
     Assert.ThrowsException <FormatException>(() => { HeroesDataVersion.Parse(value); });
     Assert.ThrowsException <FormatException>(() => { HeroesDataVersion.Parse(value.AsSpan()); });
 }
コード例 #14
0
 public void TryParseFailTest(string?value)
 {
     Assert.IsFalse(HeroesDataVersion.TryParse(value, out HeroesDataVersion? _));
     Assert.IsFalse(HeroesDataVersion.TryParse(value.AsSpan(), out HeroesDataVersion? _));
 }
コード例 #15
0
        public void NotEqualsTest(int major, int minor, int revision, int build, bool isPtr = false)
        {
            HeroesDataVersion heroesVersion = new HeroesDataVersion(1, 1, 1, 11111, true);

            Assert.AreNotEqual(heroesVersion, new HeroesDataVersion(major, minor, revision, build, isPtr));
        }