Skip to content

Commit 4836307

Browse files
committed
Test asset disallowance case-insensitivety, test IsAssetDisallowed method
1 parent 5e7478b commit 4836307

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

RefreshTests.GameServer/Tests/Assets/AssetDisallowanceTests.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,42 @@ namespace RefreshTests.GameServer.Tests.Assets;
1414
public class AssetDisallowanceTests : GameServerTest
1515
{
1616
[Test]
17-
public void CanDisallowAndReallowAsset()
17+
[TestCase("trash")]
18+
[TestCase("Trash")]
19+
[TestCase("TRASH")]
20+
public void CanDisallowAndReallowAssetCaseInsensitively(string hash)
1821
{
1922
using TestContext context = this.GetServer();
2023

21-
string hash = "trash";
24+
string hashLower = hash.ToLower();
2225
GameAssetType type = GameAssetType.Mesh;
2326

2427
// Ensure that the asset isn't already disallowed
28+
Assert.That(context.Database.IsAssetDisallowed(hash), Is.False);
2529
Assert.That(context.Database.GetDisallowedAssetInfo(hash), Is.Null);
2630

2731
// Disallow
2832
(DisallowedAsset disallowed, bool success) = context.Database.DisallowAsset(hash, type, "too ugly");
2933
Assert.That(success, Is.True);
30-
Assert.That(disallowed.AssetHash, Is.EqualTo(hash));
34+
Assert.That(disallowed.AssetHash, Is.EqualTo(hashLower));
3135
Assert.That(disallowed.AssetType, Is.EqualTo(type));
3236
Assert.That(disallowed.Reason, Is.EqualTo("too ugly"));
37+
context.Database.Refresh();
3338

34-
// Ensure that the same entity is gotten again, and the DB method doesn't try to insert a new one
39+
// Try to disallow again, and ensure the DB method doesn't try to insert a new one
3540
(disallowed, success) = context.Database.DisallowAsset(hash, type, "too ugly");
3641
Assert.That(success, Is.False);
37-
Assert.That(disallowed.AssetHash, Is.EqualTo(hash));
42+
Assert.That(disallowed.AssetHash, Is.EqualTo(hashLower));
3843
Assert.That(disallowed.AssetType, Is.EqualTo(type));
3944
Assert.That(disallowed.Reason, Is.EqualTo("too ugly"));
45+
context.Database.Refresh();
4046

4147
// ensure that the separately gotten entity is also the same
48+
Assert.That(context.Database.IsAssetDisallowed(hash), Is.True);
4249
DisallowedAsset? gottenAgain = context.Database.GetDisallowedAssetInfo(hash);
4350
Assert.That(gottenAgain, Is.Not.Null);
4451
Assert.That(success, Is.False);
45-
Assert.That(disallowed.AssetHash, Is.EqualTo(hash));
52+
Assert.That(disallowed.AssetHash, Is.EqualTo(hashLower));
4653
Assert.That(disallowed.AssetType, Is.EqualTo(type));
4754
Assert.That(disallowed.Reason, Is.EqualTo("too ugly"));
4855

@@ -52,11 +59,13 @@ public void CanDisallowAndReallowAsset()
5259
// Reallow
5360
success = context.Database.ReallowAsset(hash);
5461
Assert.That(success, Is.True);
62+
Assert.That(context.Database.IsAssetDisallowed(hash), Is.False);
5563
Assert.That(context.Database.GetDisallowedAssetInfo(hash), Is.Null);
5664

5765
// Reallow again
5866
success = context.Database.ReallowAsset(hash);
5967
Assert.That(success, Is.False);
68+
Assert.That(context.Database.IsAssetDisallowed(hash), Is.False);
6069
Assert.That(context.Database.GetDisallowedAssetInfo(hash), Is.Null);
6170
}
6271

0 commit comments

Comments
 (0)