diff --git a/Refresh.Core/Helpers/ResourceValidationHelper.cs b/Refresh.Core/Helpers/ResourceValidationHelper.cs index 2efb5b6ec..8d6b53916 100644 --- a/Refresh.Core/Helpers/ResourceValidationHelper.cs +++ b/Refresh.Core/Helpers/ResourceValidationHelper.cs @@ -20,38 +20,37 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p GameAsset? asset = null; bool existsInDataStore = false; bool isPSP = parameters.GameToUseIn == TokenGame.LittleBigPlanetPSP; - Action? onNewAssetRefCallback = parameters.OnNewAssetRefCallback; if (parameters.AssetRef.IsBlankHash()) { - if (!parameters.MayBeBlank) return new(BadRequest, "0", $"The {assetTypeStr} must be set.", onNewAssetRefCallback); - else return new(OK, "0", null, onNewAssetRefCallback); + if (!parameters.MayBeBlank) return new(BadRequest, "0", $"The {assetTypeStr} must be set."); + else return new(OK, "0", null); } else if (parameters.AssetRef.StartsWith('g')) { - if (!parameters.MayBeGuid) return new(BadRequest, null, $"The {assetTypeStr} may not be an in-game asset.", onNewAssetRefCallback); - if (parameters.AssetRef.Length < 2) return new(BadRequest, null, $"The used in-game {assetTypeStr} is invalid (empty GUID).", onNewAssetRefCallback); + if (!parameters.MayBeGuid) return new(BadRequest, null, $"The {assetTypeStr} may not be an in-game asset."); + if (parameters.AssetRef.Length < 2) return new(BadRequest, null, $"The used in-game {assetTypeStr} is invalid (empty GUID)."); // This should only happen if the user is messing with mods/the API/beta builds, so give them a more detailed response bool canParseGuid = long.TryParse(parameters.AssetRef[1..], out long guid); if (!canParseGuid) - return new(BadRequest, null, $"The used in-game {assetTypeStr} is invalid (badly formatted GUID).", onNewAssetRefCallback); + return new(BadRequest, null, $"The used in-game {assetTypeStr} is invalid (badly formatted GUID)."); if (parameters.MustBeTexture && !parameters.GuidChecker.IsTextureGuid(parameters.GameToUseIn, guid)) - return new(BadRequest, null, $"The used in-game {assetTypeStr} was not a valid image (unknown GUID).", onNewAssetRefCallback); + return new(BadRequest, null, $"The used in-game {assetTypeStr} was not a valid image (unknown GUID)."); } // At this point the reference is a hash else if (!parameters.MayBeHash) { - return new(BadRequest, null, $"The {assetTypeStr} may not be a custom asset.", onNewAssetRefCallback); + return new(BadRequest, null, $"The {assetTypeStr} may not be a custom asset."); } else if (!CommonPatterns.Sha1Regex().IsMatch(parameters.AssetRef)) { // This should only happen if a player is messing with mods/the API, so give them a more detailed response - return new(BadRequest, null, $"The used {assetTypeStr} had an invalid hash.", onNewAssetRefCallback); + return new(BadRequest, null, $"The used {assetTypeStr} had an invalid hash."); } else @@ -60,7 +59,7 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p if (disallowed != null) { logger.LogWarning(BunkumCategory.UserContent, $"{parameters.User} tried to use a manually disallowed {assetTypeStr}."); - return new(Unauthorized, disallowanceInfo: disallowed, onNewAssetRefCallback: onNewAssetRefCallback); + return new(Unauthorized, disallowanceInfo: disallowed); } string filename = isPSP ? $"psp/{parameters.AssetRef}" : parameters.AssetRef; @@ -71,7 +70,7 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p logger.LogDebug(BunkumCategory.UserContent, $"Referenced asset '{filename}' could not be found in data store."); if (parameters.MustBeInDataStoreIfHash) - return new(NotFound, null, $"The used {assetTypeStr} did not exist on the server.", onNewAssetRefCallback); + return new(NotFound, null, $"The used {assetTypeStr} did not exist on the server."); } asset = parameters.Cache.GetAssetInfo(parameters.AssetRef, parameters.Database); @@ -88,7 +87,7 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p sw.Stop(); logger.LogError(BunkumCategory.UserContent, $"Failed to read '{filename}' from data store!"); logger.LogDebug(BunkumCategory.UserContent, $"Failed to get '{filename}' after {sw.ElapsedMilliseconds}ms."); - return new(InternalServerError, null, $"Failed to read {assetTypeStr} internally. Please report this to the server owner.", onNewAssetRefCallback, existsInDataStore: existsInDataStore); + return new(InternalServerError, null, $"Failed to read {assetTypeStr} internally. Please report this to the server owner.", existsInDataStore: existsInDataStore); } asset = parameters.AssetImporter.ReadAndVerifyAsset(parameters.AssetRef, assetData, parameters.PlatformToUseIn, parameters.Database); @@ -96,7 +95,7 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p { sw.Stop(); logger.LogDebug(BunkumCategory.UserContent, $"Failed to get '{filename}' after {sw.ElapsedMilliseconds}ms."); - return new(BadRequest, null, $"The used {assetTypeStr} was invalid or corrupt.", onNewAssetRefCallback, existsInDataStore: existsInDataStore); + return new(BadRequest, null, $"The used {assetTypeStr} was invalid or corrupt.", existsInDataStore: existsInDataStore); } sw.Stop(); @@ -109,12 +108,12 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p bool isHashedTexture = (asset.AssetFlags & AssetFlags.Imagery) != 0; if (parameters.MustBeTexture && !isHashedTexture) - return new(BadRequest, null, $"The used {assetTypeStr} was not a valid custom image.", onNewAssetRefCallback, assetInfo: asset, existsInDataStore: existsInDataStore); + return new(BadRequest, null, $"The used {assetTypeStr} was not a valid custom image.", assetInfo: asset, existsInDataStore: existsInDataStore); // TODO: actually use AIPI to scan image if not null } } - return new(OK, parameters.AssetRef, null, onNewAssetRefCallback, assetInfo: asset, existsInDataStore: existsInDataStore); + return new(OK, parameters.AssetRef, assetInfo: asset, existsInDataStore: existsInDataStore); } } \ No newline at end of file diff --git a/Refresh.Core/Types/Assets/Validation/AssetValidationParameters.cs b/Refresh.Core/Types/Assets/Validation/AssetValidationParameters.cs index b83f4caed..ec87abf01 100644 --- a/Refresh.Core/Types/Assets/Validation/AssetValidationParameters.cs +++ b/Refresh.Core/Types/Assets/Validation/AssetValidationParameters.cs @@ -34,19 +34,11 @@ public struct AssetValidationParameters /// What the asset should be referred as in user-faced error messages and in logs, e.g. "planet asset" or "icon". /// If null, we will default to calling it "asset" or "image" depending on MustBeTexture. /// - public string? AssetContextTypeStr { get; set; } + public string? AssetContextTypeStr { get; set; } // TODO think of a better name - /// - /// Callback which is called with the new asset reference as parameter when constructing ; - /// useful to update asset references of entities during validation without requiring the caller to manually reassign them after validation; - /// this way similar attributes like photo images or face icons can simply be iterated. - /// If null, this will be skipped. - /// - public Action? OnNewAssetRefCallback { get; set; } - - public AssetValidationParameters(string assetKey, DataContext dataContext, AssetImporter assetImporter, AipiService? aipi = null) + public AssetValidationParameters(string assetRef, DataContext dataContext, AssetImporter assetImporter, AipiService? aipi = null) { - this.AssetRef = assetKey; + this.AssetRef = assetRef; this.User = dataContext.User; this.GameToUseIn = dataContext.Game; this.PlatformToUseIn = dataContext.Platform; diff --git a/Refresh.Core/Types/Assets/Validation/ValidatedAssetResult.cs b/Refresh.Core/Types/Assets/Validation/ValidatedAssetResult.cs index 59049ba30..7f197cbe9 100644 --- a/Refresh.Core/Types/Assets/Validation/ValidatedAssetResult.cs +++ b/Refresh.Core/Types/Assets/Validation/ValidatedAssetResult.cs @@ -26,7 +26,7 @@ public struct ValidatedAssetResult public DisallowedAsset? DisallowanceInfo { get; set; } public bool ExistsInDataStore { get; set; } - public ValidatedAssetResult(HttpStatusCode status, string? newAssetRef = null, string? errorMessage = null, Action? onNewAssetRefCallback = null, + public ValidatedAssetResult(HttpStatusCode status, string? newAssetRef = null, string? errorMessage = null, GameAsset? assetInfo = null, DisallowedAsset? disallowanceInfo = null, bool existsInDataStore = false) { this.Status = status; @@ -35,7 +35,5 @@ public ValidatedAssetResult(HttpStatusCode status, string? newAssetRef = null, s this.AssetInfo = assetInfo; this.DisallowanceInfo = disallowanceInfo; this.ExistsInDataStore = existsInDataStore; - - onNewAssetRefCallback?.Invoke(this.NewAssetRef); } } \ No newline at end of file diff --git a/RefreshTests.GameServer/Tests/Assets/AssetReferenceValidationTests.cs b/RefreshTests.GameServer/Tests/Assets/AssetReferenceValidationTests.cs index 9d986af37..afe65eff6 100644 --- a/RefreshTests.GameServer/Tests/Assets/AssetReferenceValidationTests.cs +++ b/RefreshTests.GameServer/Tests/Assets/AssetReferenceValidationTests.cs @@ -27,14 +27,10 @@ public void AcceptBlankHash(string blankHashVariation) DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; - ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(blankHashVariation, dataContext, importer) - { - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, - }, dataContext.Logger); + ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(blankHashVariation, dataContext, importer), dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(OK)); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); Assert.That(result.AssetInfo, Is.Null); } @@ -51,16 +47,14 @@ public void RejectBlankHashIfDisallowed(string blankHashVariation) DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(blankHashVariation, dataContext, importer) { MayBeBlank = false, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(BadRequest)); Assert.That(result.ErrorMessage, Is.Not.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -74,14 +68,10 @@ public void AcceptGuidsIfNotRestricted(string guid) DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; - ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer) - { - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, - }, dataContext.Logger); + ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer), dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(OK)); Assert.That(result.NewAssetRef, Is.EqualTo(guid)); - Assert.That(newRefSetByCallback, Is.EqualTo(guid)); Assert.That(result.ErrorMessage, Is.Null); } @@ -96,16 +86,14 @@ public void RejectGuidIfDisallowed(string guid) DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer) { MayBeGuid = false, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(BadRequest)); Assert.That(result.ErrorMessage, Is.Not.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -120,15 +108,11 @@ public void RejectGuidIfBadlyFormatted(string guid) DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; - ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer) - { - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, - }, dataContext.Logger); + ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer), dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(BadRequest)); Assert.That(result.ErrorMessage, Is.Not.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -141,16 +125,14 @@ public void RejectNonTextureGuidIfOnlyTexturesAllowed() DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer) { MustBeTexture = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(BadRequest)); Assert.That(result.ErrorMessage, Is.Not.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -163,16 +145,14 @@ public void AcceptTextureGuidIfOnlyTexturesAllowed() DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(guid, dataContext, importer) { MustBeTexture = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); + Assert.That(result.Status, Is.EqualTo(OK)); Assert.That(result.AssetInfo, Is.Null); Assert.That(result.NewAssetRef, Is.EqualTo(guid)); - Assert.That(newRefSetByCallback, Is.EqualTo(guid)); } [Test] @@ -198,11 +178,9 @@ public void AcceptOrRejectHashDependingOnExistenceInDataStore(bool addToDataStor dataContext.DataStore.WriteToStore(hash, data); } - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeInDataStoreIfHash = mustBeInDataStore, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); if (expectDataStoreFailure) @@ -210,7 +188,6 @@ public void AcceptOrRejectHashDependingOnExistenceInDataStore(bool addToDataStor Assert.That(result.Status, Is.EqualTo(NotFound)); Assert.That(result.AssetInfo, Is.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } else if (addToDataStore) { @@ -219,14 +196,12 @@ public void AcceptOrRejectHashDependingOnExistenceInDataStore(bool addToDataStor Assert.That(result.AssetInfo!.AssetHash, Is.EqualTo(hash)); Assert.That(result.AssetInfo!.AssetType, Is.EqualTo(GameAssetType.Level)); Assert.That(result.NewAssetRef, Is.EqualTo(hash)); - Assert.That(newRefSetByCallback, Is.EqualTo(hash)); } else { Assert.That(result.Status, Is.EqualTo(OK)); Assert.That(result.AssetInfo, Is.Null); // not auto-imported and also not in DB before Assert.That(result.NewAssetRef, Is.EqualTo(hash)); - Assert.That(newRefSetByCallback, Is.EqualTo(hash)); } Assert.That(result.DisallowanceInfo, Is.Null); @@ -247,11 +222,9 @@ public void RejectHashIfReadingFromDataStoreFails() ReadOnlySpan data = "LVLb"u8; string hash = BitConverter.ToString(SHA1.HashData(data)).Replace("-", "").ToLower(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeInDataStoreIfHash = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(InternalServerError)); @@ -259,7 +232,6 @@ public void RejectHashIfReadingFromDataStoreFails() Assert.That(result.DisallowanceInfo, Is.Null); Assert.That(result.ExistsInDataStore, Is.True); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -276,11 +248,9 @@ public void RejectHashIfImportingFromDataStoreFails() string fakeHash = BitConverter.ToString(SHA1.HashData("veryreallevel"u8)).Replace("-", "").ToLower(); dataContext.DataStore.WriteToStore(fakeHash, data); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(fakeHash, dataContext, importer) { MustBeInDataStoreIfHash = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(BadRequest)); @@ -289,7 +259,6 @@ public void RejectHashIfImportingFromDataStoreFails() Assert.That(result.ExistsInDataStore, Is.True); Assert.That(result.ErrorMessage, Is.Not.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -301,11 +270,9 @@ public void RejectHashIfInvalidHash() DataContext dataContext = context.GetDataContext(token); AssetImporter importer = new(dataContext.Logger, context.Time); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new("lololol", dataContext, importer) { MustBeInDataStoreIfHash = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(BadRequest)); @@ -313,7 +280,6 @@ public void RejectHashIfInvalidHash() Assert.That(result.DisallowanceInfo, Is.Null); Assert.That(result.ExistsInDataStore, Is.False); // Cancelled before actually wasting time looking it up Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -331,11 +297,9 @@ public void RejectHashIfAssetDisallowed() context.Database.Refresh(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeInDataStoreIfHash = true, // Ensure disallowance is checked before the data store check - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(Unauthorized)); @@ -343,7 +307,6 @@ public void RejectHashIfAssetDisallowed() Assert.That(result.AssetInfo, Is.Null); Assert.That(result.DisallowanceInfo, Is.Not.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -358,11 +321,9 @@ public void RejectHashIfHashesDisallowed() ReadOnlySpan data = "LVLb"u8; string hash = BitConverter.ToString(SHA1.HashData(data)).Replace("-", "").ToLower(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MayBeHash = false, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(BadRequest)); @@ -370,7 +331,6 @@ public void RejectHashIfHashesDisallowed() Assert.That(result.AssetInfo, Is.Null); Assert.That(result.DisallowanceInfo, Is.Null); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); } [Test] @@ -396,17 +356,14 @@ public void AcceptTextureHashIfOnlyTexturesAllowed(bool addToDataStore) context.Database.Refresh(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeTexture = true, MustBeInDataStoreIfHash = false, // not tested in this one - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(OK)); Assert.That(result.NewAssetRef, Is.EqualTo(hash)); - Assert.That(newRefSetByCallback, Is.EqualTo(hash)); Assert.That(result.AssetInfo, Is.Not.Null); Assert.That(result.AssetInfo!.AssetHash, Is.EqualTo(hash)); Assert.That(result.AssetInfo!.AssetType, Is.EqualTo(GameAssetType.Texture)); @@ -437,17 +394,14 @@ public void RejectNonTextureHashIfOnlyTexturesAllowed(bool addToDataStore) context.Database.Refresh(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeTexture = true, MustBeInDataStoreIfHash = false, // not tested in this one - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(BadRequest)); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); Assert.That(result.AssetInfo, Is.Not.Null); Assert.That(result.AssetInfo!.AssetHash, Is.EqualTo(hash)); Assert.That(result.AssetInfo!.AssetType, Is.EqualTo(GameAssetType.Level)); @@ -472,17 +426,14 @@ public void AcceptsIfMustBeTextureButUnreadablePSPAsset() context.Database.Refresh(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeTexture = true, MustBeInDataStoreIfHash = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(OK)); Assert.That(result.NewAssetRef, Is.EqualTo(hash)); - Assert.That(newRefSetByCallback, Is.EqualTo(hash)); Assert.That(result.AssetInfo, Is.Not.Null); Assert.That(result.AssetInfo!.AssetHash, Is.EqualTo(hash)); Assert.That(result.AssetInfo!.AssetType, Is.EqualTo(GameAssetType.Unknown)); @@ -506,17 +457,14 @@ public void RejectsIfMustBeTextureAndUnreadableNonPSPAsset() context.Database.Refresh(); - string newRefSetByCallback = "unset lol"; ValidatedAssetResult result = ResourceValidationHelper.ValidateReference(new(hash, dataContext, importer) { MustBeTexture = true, MustBeInDataStoreIfHash = true, - OnNewAssetRefCallback = delegate(string NewAssetRef) { newRefSetByCallback = NewAssetRef; }, }, dataContext.Logger); Assert.That(result.Status, Is.EqualTo(BadRequest)); Assert.That(result.NewAssetRef, Is.EqualTo("0")); - Assert.That(newRefSetByCallback, Is.EqualTo("0")); Assert.That(result.AssetInfo, Is.Not.Null); Assert.That(result.AssetInfo!.AssetHash, Is.EqualTo(hash)); Assert.That(result.AssetInfo!.AssetType, Is.EqualTo(GameAssetType.Unknown));