mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-19 15:58:39 +00:00
Modernize unit tests
This commit is contained in:
@@ -6,9 +6,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ConfigureAwaitChecker.Analyzer" PrivateAssets="all" />
|
<PackageReference Include="ConfigureAwaitChecker.Analyzer" PrivateAssets="all" />
|
||||||
<PackageReference Include="JetBrains.Annotations" PrivateAssets="all" />
|
<PackageReference Include="JetBrains.Annotations" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
<PackageReference Include="MSTest" />
|
||||||
<PackageReference Include="MSTest.TestAdapter" />
|
|
||||||
<PackageReference Include="MSTest.TestFramework" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public sealed class Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
||||||
public void MaxItemsTooSmall() {
|
public void MaxItemsTooSmall() {
|
||||||
const uint appID = 42;
|
const uint appID = 42;
|
||||||
|
|
||||||
@@ -64,9 +63,7 @@ public sealed class Bot {
|
|||||||
CreateCard(2, appID)
|
CreateCard(2, appID)
|
||||||
];
|
];
|
||||||
|
|
||||||
GetItemsForFullBadge(items, 2, appID, MinCardsPerBadge - 1);
|
Assert.ThrowsException<ArgumentOutOfRangeException>(() => GetItemsForFullBadge(items, 2, appID, MinCardsPerBadge - 1));
|
||||||
|
|
||||||
Assert.Fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -460,7 +457,6 @@ public sealed class Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[ExpectedException(typeof(InvalidOperationException))]
|
|
||||||
public void TooManyCardsPerSet() {
|
public void TooManyCardsPerSet() {
|
||||||
const uint appID0 = 42;
|
const uint appID0 = 42;
|
||||||
const uint appID1 = 43;
|
const uint appID1 = 43;
|
||||||
@@ -473,15 +469,15 @@ public sealed class Bot {
|
|||||||
CreateCard(4, appID0)
|
CreateCard(4, appID0)
|
||||||
];
|
];
|
||||||
|
|
||||||
GetItemsForFullBadge(
|
Assert.ThrowsException<InvalidOperationException>(
|
||||||
|
() => GetItemsForFullBadge(
|
||||||
items, new Dictionary<uint, byte> {
|
items, new Dictionary<uint, byte> {
|
||||||
{ appID0, 3 },
|
{ appID0, 3 },
|
||||||
{ appID1, 3 },
|
{ appID1, 3 },
|
||||||
{ appID2, 3 }
|
{ appID2, 3 }
|
||||||
}
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.Fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AssertResultMatchesExpectation(IReadOnlyDictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult, IReadOnlyCollection<Asset> itemsToSend) {
|
private static void AssertResultMatchesExpectation(IReadOnlyDictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult, IReadOnlyCollection<Asset> itemsToSend) {
|
||||||
|
|||||||
@@ -311,27 +311,21 @@ public sealed class SteamChatMessage {
|
|||||||
Assert.AreEqual(newlinePart, output[3]);
|
Assert.AreEqual(newlinePart, output[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task ThrowsOnTooLongNewlinesPrefix() {
|
public async Task ThrowsOnTooLongNewlinesPrefix() {
|
||||||
string prefix = new('\n', (MaxMessagePrefixBytes / NewlineWeight) + 1);
|
string prefix = new('\n', (MaxMessagePrefixBytes / NewlineWeight) + 1);
|
||||||
|
|
||||||
const string message = "asdf";
|
const string message = "asdf";
|
||||||
|
|
||||||
await GetMessageParts(message, prefix).ToListAsync().ConfigureAwait(false);
|
await Assert.ThrowsExceptionAsync<ArgumentOutOfRangeException>(async () => await GetMessageParts(message, prefix).ToListAsync().ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
|
|
||||||
Assert.Fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task ThrowsOnTooLongPrefix() {
|
public async Task ThrowsOnTooLongPrefix() {
|
||||||
string prefix = new('x', MaxMessagePrefixBytes + 1);
|
string prefix = new('x', MaxMessagePrefixBytes + 1);
|
||||||
|
|
||||||
const string message = "asdf";
|
const string message = "asdf";
|
||||||
|
|
||||||
await GetMessageParts(message, prefix).ToListAsync().ConfigureAwait(false);
|
await Assert.ThrowsExceptionAsync<ArgumentOutOfRangeException>(async () => await GetMessageParts(message, prefix).ToListAsync().ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
|
|
||||||
Assert.Fail();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@
|
|||||||
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0" />
|
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0" />
|
||||||
<PackageVersion Include="Markdig.Signed" Version="0.35.0" />
|
<PackageVersion Include="Markdig.Signed" Version="0.35.0" />
|
||||||
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.3.1" />
|
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.3.1" />
|
||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
<PackageVersion Include="MSTest" Version="3.2.2" />
|
||||||
<PackageVersion Include="MSTest.TestAdapter" Version="3.2.1" />
|
|
||||||
<PackageVersion Include="MSTest.TestFramework" Version="3.2.1" />
|
|
||||||
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
|
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
|
||||||
<PackageVersion Include="NLog.Web.AspNetCore" Version="5.3.8" />
|
<PackageVersion Include="NLog.Web.AspNetCore" Version="5.3.8" />
|
||||||
<PackageVersion Include="SteamKit2" Version="2.5.0" />
|
<PackageVersion Include="SteamKit2" Version="2.5.0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user