public void NotSameObjectTest() { HeroesDataVersion heroesVersion = new HeroesDataVersion(1, 1, 1, 11111, true); Assert.AreNotEqual(new List <string>() { "asdf" }, heroesVersion); }
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)); }
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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
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)); }
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); }
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()); }); }
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); }
public void ParseFailTest(string value) { Assert.ThrowsException <FormatException>(() => { HeroesDataVersion.Parse(value); }); Assert.ThrowsException <FormatException>(() => { HeroesDataVersion.Parse(value.AsSpan()); }); }
public void TryParseFailTest(string?value) { Assert.IsFalse(HeroesDataVersion.TryParse(value, out HeroesDataVersion? _)); Assert.IsFalse(HeroesDataVersion.TryParse(value.AsSpan(), out HeroesDataVersion? _)); }
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)); }