This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from aspriddell/rewrite-tests
Re-write tests
- Loading branch information
Showing
28 changed files
with
333 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
DragonFruit.Six.API.Tests.Common/DragonFruit.Six.API.Tests.Common.csproj
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Dragon6 API Copyright 2020 DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Please refer to the LICENSE file for more info | ||
|
||
using System; | ||
using System.Globalization; | ||
using DragonFruit.Six.API.Data.Extensions; | ||
using DragonFruit.Six.API.Enums; | ||
using NUnit.Framework; | ||
|
||
namespace DragonFruit.Six.API.Tests.Data | ||
{ | ||
[TestFixture] | ||
public class AccountActivityTests : Dragon6ApiTest | ||
{ | ||
[TestCase("14c01250-ef26-4a32-92ba-e04aa557d619", Platform.PC, 20201201)] | ||
[TestCase("352655b3-2ff4-4713-9ad5-c10eb080e6f6", Platform.PC, 20200901)] | ||
[TestCase("a5e7c9c4-a225-4d8e-810f-0c529d829a34", Platform.PSN, 20191001)] | ||
public void TestAccountActivity(string id, Platform platform, int lastLogin) | ||
{ | ||
if (!DateTime.TryParseExact(lastLogin.ToString(), "yyyyMMdd", null, DateTimeStyles.None, out var lastLoginDate)) | ||
{ | ||
Assert.Inconclusive($"{nameof(lastLogin)} was in an invalid format"); | ||
} | ||
|
||
var account = GetAccountInfoFor(id, platform); | ||
var login = Client.GetLoginInfo(account); | ||
|
||
Assert.IsTrue(login.Activity.Last.UtcDateTime.Date > lastLoginDate.Date); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Dragon6 API Copyright 2020 DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Please refer to the LICENSE file for more info | ||
|
||
using System; | ||
using DragonFruit.Six.API.Data.Extensions; | ||
using DragonFruit.Six.API.Enums; | ||
using NUnit.Framework; | ||
|
||
namespace DragonFruit.Six.API.Tests.Data | ||
{ | ||
[TestFixture] | ||
public class AccountLookupTests : Dragon6ApiTest | ||
{ | ||
[TestCase("papa.curry", LookupMethod.Name)] | ||
[TestCase("Frost_Bites_", LookupMethod.Name)] | ||
[TestCase("a5e7c9c4-a225-4d8e-810f-0c529d829a34", LookupMethod.UserId, Platform.PSN)] | ||
[TestCase("b6c8e00a-00f9-44fb-b83e-eb9135933b91", LookupMethod.UserId, Platform.XB1)] | ||
public void TestAccountLookup(string identifier, LookupMethod method, Platform platform = Platform.PC) | ||
{ | ||
var account = Client.GetUser(platform, method, identifier); | ||
|
||
Assert.IsTrue(method switch | ||
{ | ||
LookupMethod.Name => identifier.Equals(account.PlayerName, StringComparison.OrdinalIgnoreCase), | ||
LookupMethod.UserId => identifier.Equals(account.Identifiers.Ubisoft), | ||
LookupMethod.PlatformId => identifier.Equals(account.Identifiers.Platform), | ||
|
||
_ => throw new ArgumentOutOfRangeException(nameof(method), method, null) | ||
}); | ||
} | ||
|
||
[TestCase("l52655b3-2ff4-4713-9ad5-c10eb080e6f6")] | ||
[TestCase("352655b3-2ff4-4713-xxxx-c10eb080e6f6")] | ||
public void TestInvalidAccountLookup(string identifier) | ||
{ | ||
Assert.Catch<ArgumentException>(() => Client.GetUserByUbisoftId(identifier, Platform.PC)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Dragon6 API Copyright 2020 DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Please refer to the LICENSE file for more info | ||
|
||
using DragonFruit.Six.API.Data.Extensions; | ||
using DragonFruit.Six.API.Enums; | ||
using DragonFruit.Six.API.Utils; | ||
using NUnit.Framework; | ||
|
||
namespace DragonFruit.Six.API.Tests.Data | ||
{ | ||
[TestFixture] | ||
public class GeneralStatsTests : Dragon6ApiTest | ||
{ | ||
private static object[] _accounts = | ||
{ | ||
new object[] { "14c01250-ef26-4a32-92ba-e04aa557d619", Platform.PC }, | ||
new object[] { "b6c8e00a-00f9-44fb-b83e-eb9135933b91", Platform.XB1 }, | ||
new object[] { "a5e7c9c4-a225-4d8e-810f-0c529d829a34", Platform.PSN } | ||
}; | ||
|
||
[Test] | ||
[TestCaseSource(nameof(_accounts))] | ||
public void GeneralStatsTest(string identifier, Platform platform) | ||
{ | ||
var account = GetAccountInfoFor(identifier, platform); | ||
Client.GetStats(account); | ||
} | ||
|
||
[Test] | ||
[TestCaseSource(nameof(_accounts))] | ||
public void WeaponStatsTest(string identifier, Platform platform) | ||
{ | ||
var account = GetAccountInfoFor(identifier, platform); | ||
Client.GetWeaponStats(account); | ||
} | ||
|
||
[Test] | ||
[TestCaseSource(nameof(_accounts))] | ||
public void PlayerLevelStatsTest(string identifier, Platform platform) | ||
{ | ||
var account = GetAccountInfoFor(identifier, platform); | ||
Client.GetLevel(account); | ||
} | ||
|
||
[Test] | ||
[TestCaseSource(nameof(_accounts))] | ||
public void PlayerOperatorStatsTest(string identifier, Platform platform) | ||
{ | ||
OperatorInfo ??= Client.GetOperatorInfo(); | ||
|
||
var account = GetAccountInfoFor(identifier, platform); | ||
Client.GetOperatorStats(account, OperatorInfo); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Dragon6 API Copyright 2020 DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Please refer to the LICENSE file for more info | ||
|
||
using DragonFruit.Six.API.Data.Extensions; | ||
using DragonFruit.Six.API.Enums; | ||
using NUnit.Framework; | ||
|
||
namespace DragonFruit.Six.API.Tests.Data | ||
{ | ||
[TestFixture] | ||
public class SeasonalStatsTests : Dragon6ApiTest | ||
{ | ||
[TestCase("14c01250-ef26-4a32-92ba-e04aa557d619", Platform.PC, 17, 17)] | ||
public void TestSeasonalStats(string identifier, Platform platform, int season, int maxRank) | ||
{ | ||
var account = GetAccountInfoFor(identifier, platform); | ||
var stats = Client.GetSeasonStats(account, season); | ||
|
||
Assert.AreEqual(maxRank, stats.MaxRank); | ||
} | ||
|
||
[TestCase("14c01250-ef26-4a32-92ba-e04aa557d619", Platform.PC, "EMEA", 10, 13)] | ||
public void TestLegacySeasonalStats(string identifier, Platform platform, string region, int season, int maxRank) | ||
{ | ||
var account = GetAccountInfoFor(identifier, platform); | ||
var stats = Client.GetSeasonStats(account, region, season); | ||
|
||
Assert.AreEqual(maxRank, stats.MaxRank); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Dragon6 API Copyright 2020 DragonFruit Network <inbox@dragonfruit.network> | ||
// Licensed under Apache-2. Please refer to the LICENSE file for more info | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using DragonFruit.Six.API.Data; | ||
using DragonFruit.Six.API.Data.Extensions; | ||
using DragonFruit.Six.API.Enums; | ||
|
||
namespace DragonFruit.Six.API.Tests | ||
{ | ||
public abstract class Dragon6ApiTest | ||
{ | ||
private static readonly List<AccountInfo> Accounts = new(); | ||
protected static readonly Dragon6TestClient Client = new(); | ||
|
||
protected static IEnumerable<OperatorStats> OperatorInfo { get; set; } | ||
|
||
protected AccountInfo GetAccountInfoFor(string identifier, Platform platform) | ||
{ | ||
var account = Accounts.SingleOrDefault(x => identifier == x.Identifiers.Ubisoft); | ||
|
||
if (account != null) | ||
{ | ||
return account; | ||
} | ||
|
||
var onlineAccount = Client.GetUser(platform, LookupMethod.UserId, identifier); | ||
Accounts.Add(onlineAccount); | ||
|
||
return onlineAccount; | ||
} | ||
} | ||
} |
Oops, something went wrong.