summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Tests')
-rw-r--r--src/SMAPI.Tests/Core/AssetNameTests.cs16
-rw-r--r--src/SMAPI.Tests/Core/InterfaceProxyTests.cs103
-rw-r--r--src/SMAPI.Tests/Core/ModResolverTests.cs60
3 files changed, 120 insertions, 59 deletions
diff --git a/src/SMAPI.Tests/Core/AssetNameTests.cs b/src/SMAPI.Tests/Core/AssetNameTests.cs
index a1712726..655e9bae 100644
--- a/src/SMAPI.Tests/Core/AssetNameTests.cs
+++ b/src/SMAPI.Tests/Core/AssetNameTests.cs
@@ -78,9 +78,9 @@ namespace SMAPI.Tests.Core
[TestCase("DATA\\achievements", "data/ACHIEVEMENTS", ExpectedResult = true)]
[TestCase("DATA\\\\achievements", "data////ACHIEVEMENTS", ExpectedResult = true)]
- // whitespace-sensitive
- [TestCase("Data/Achievements", " Data/Achievements ", ExpectedResult = false)]
- [TestCase(" Data/Achievements ", "Data/Achievements", ExpectedResult = false)]
+ // whitespace-insensitive
+ [TestCase("Data/Achievements", " Data/Achievements ", ExpectedResult = true)]
+ [TestCase(" Data/Achievements ", "Data/Achievements", ExpectedResult = true)]
// other is null or whitespace
[TestCase("Data/Achievements", null, ExpectedResult = false)]
@@ -109,7 +109,7 @@ namespace SMAPI.Tests.Core
[TestCase("Data/Achievements", "Data/Achievements", ExpectedResult = true)]
[TestCase("DATA/achievements", "data/ACHIEVEMENTS", ExpectedResult = true)]
[TestCase("DATA\\\\achievements", "data////ACHIEVEMENTS", ExpectedResult = true)]
- [TestCase(" Data/Achievements ", "Data/Achievements", ExpectedResult = false)]
+ [TestCase(" Data/Achievements ", "Data/Achievements", ExpectedResult = true)]
[TestCase("Data/Achievements", " ", ExpectedResult = false)]
// with locale codes
@@ -141,13 +141,13 @@ namespace SMAPI.Tests.Core
[TestCase("DATA\\achievements", "data/ACHIEVEMENTS", ExpectedResult = true)]
[TestCase("DATA\\\\achievements", "data////ACHIEVEMENTS", ExpectedResult = true)]
- // leading-whitespace-sensitive
- [TestCase("Data/Achievements", " Data/Achievements", ExpectedResult = false)]
- [TestCase(" Data/Achievements ", "Data/Achievements", ExpectedResult = false)]
+ // whitespace-insensitive
+ [TestCase("Data/Achievements", " Data/Achievements", ExpectedResult = true)]
+ [TestCase(" Data/Achievements ", "Data/Achievements", ExpectedResult = true)]
+ [TestCase("Data/Achievements", " ", ExpectedResult = true)]
// invalid prefixes
[TestCase("Data/Achievements", null, ExpectedResult = false)]
- [TestCase("Data/Achievements", " ", ExpectedResult = false)]
// with locale codes
[TestCase("Data/Achievements.fr-FR", "Data/Achievements", ExpectedResult = true)]
diff --git a/src/SMAPI.Tests/Core/InterfaceProxyTests.cs b/src/SMAPI.Tests/Core/InterfaceProxyTests.cs
index 0b4919ed..6be97526 100644
--- a/src/SMAPI.Tests/Core/InterfaceProxyTests.cs
+++ b/src/SMAPI.Tests/Core/InterfaceProxyTests.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Reflection;
using FluentAssertions;
using NUnit.Framework;
@@ -8,6 +9,7 @@ using SMAPI.Tests.ModApiConsumer;
using SMAPI.Tests.ModApiConsumer.Interfaces;
using SMAPI.Tests.ModApiProvider;
using StardewModdingAPI.Framework.Reflection;
+using StardewModdingAPI.Utilities;
namespace SMAPI.Tests.Core
{
@@ -27,6 +29,12 @@ namespace SMAPI.Tests.Core
/// <summary>The random number generator with which to create sample values.</summary>
private readonly Random Random = new();
+ /// <summary>Sample user inputs for season names.</summary>
+ private static readonly IInterfaceProxyFactory[] ProxyFactories = {
+ new InterfaceProxyFactory(),
+ new OriginalInterfaceProxyFactory()
+ };
+
/*********
** Unit tests
@@ -35,8 +43,9 @@ namespace SMAPI.Tests.Core
** Events
****/
/// <summary>Assert that an event field can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_EventField()
+ public void CanProxy_EventField([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
ProviderMod providerMod = new();
@@ -44,7 +53,7 @@ namespace SMAPI.Tests.Core
int expectedValue = this.Random.Next();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
new ApiConsumer().UseEventField(proxy, out Func<(int timesCalled, int lastValue)> getValues);
providerMod.RaiseEvent(expectedValue);
(int timesCalled, int lastValue) = getValues();
@@ -55,8 +64,9 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that an event property can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_EventProperty()
+ public void CanProxy_EventProperty([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
ProviderMod providerMod = new();
@@ -64,7 +74,7 @@ namespace SMAPI.Tests.Core
int expectedValue = this.Random.Next();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
new ApiConsumer().UseEventProperty(proxy, out Func<(int timesCalled, int lastValue)> getValues);
providerMod.RaiseEvent(expectedValue);
(int timesCalled, int lastValue) = getValues();
@@ -78,10 +88,10 @@ namespace SMAPI.Tests.Core
** Properties
****/
/// <summary>Assert that properties can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
/// <param name="setVia">Whether to set the properties through the <c>provider mod</c> or <c>proxy interface</c>.</param>
- [TestCase("set via provider mod")]
- [TestCase("set via proxy interface")]
- public void CanProxy_Properties(string setVia)
+ [Test]
+ public void CanProxy_Properties([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory, [Values("set via provider mod", "set via proxy interface")] string setVia)
{
// arrange
ProviderMod providerMod = new();
@@ -96,7 +106,7 @@ namespace SMAPI.Tests.Core
BindingFlags expectedEnum = BindingFlags.Instance | BindingFlags.Public;
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
switch (setVia)
{
case "set via provider mod":
@@ -196,27 +206,29 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that a simple method with no return value can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_SimpleMethod_Void()
+ public void CanProxy_SimpleMethod_Void([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
proxy.GetNothing();
}
/// <summary>Assert that a simple int method can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_SimpleMethod_Int()
+ public void CanProxy_SimpleMethod_Int([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
int expectedValue = this.Random.Next();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
int actualValue = proxy.GetInt(expectedValue);
// assert
@@ -224,15 +236,16 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that a simple object method can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_SimpleMethod_Object()
+ public void CanProxy_SimpleMethod_Object([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
object expectedValue = new();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
object actualValue = proxy.GetObject(expectedValue);
// assert
@@ -240,15 +253,16 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that a simple list method can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_SimpleMethod_List()
+ public void CanProxy_SimpleMethod_List([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
string expectedValue = this.GetRandomString();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
IList<string> actualValue = proxy.GetList(expectedValue);
// assert
@@ -256,15 +270,16 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that a simple list with interface method can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_SimpleMethod_ListWithInterface()
+ public void CanProxy_SimpleMethod_ListWithInterface([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
string expectedValue = this.GetRandomString();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
IList<string> actualValue = proxy.GetListWithInterface(expectedValue);
// assert
@@ -272,8 +287,9 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that a simple method which returns generic types can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
- public void CanProxy_SimpleMethod_GenericTypes()
+ public void CanProxy_SimpleMethod_GenericTypes([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
@@ -281,7 +297,7 @@ namespace SMAPI.Tests.Core
string expectedValue = this.GetRandomString();
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
IDictionary<string, IList<string>> actualValue = proxy.GetGenerics(expectedKey, expectedValue);
// assert
@@ -292,22 +308,61 @@ namespace SMAPI.Tests.Core
}
/// <summary>Assert that a simple lambda method can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
[Test]
[SuppressMessage("ReSharper", "ConvertToLocalFunction")]
- public void CanProxy_SimpleMethod_Lambda()
+ public void CanProxy_SimpleMethod_Lambda([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
{
// arrange
object implementation = new ProviderMod().GetModApi();
Func<string, string> expectedValue = _ => "test";
// act
- ISimpleApi proxy = this.GetProxy(implementation);
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
object actualValue = proxy.GetObject(expectedValue);
// assert
actualValue.Should().BeSameAs(expectedValue);
}
+ /// <summary>Assert that a method with out parameters can be proxied correctly.</summary>
+ /// <param name="proxyFactory">The proxy factory to test.</param>
+ [Test]
+ [SuppressMessage("ReSharper", "ConvertToLocalFunction")]
+ public void CanProxy_Method_OutParameters([ValueSource(nameof(InterfaceProxyTests.ProxyFactories))] IInterfaceProxyFactory proxyFactory)
+ {
+ // arrange
+ object implementation = new ProviderMod().GetModApi();
+ const int expectedNumber = 42;
+
+ // act
+ ISimpleApi proxy = this.GetProxy(proxyFactory, implementation);
+ bool result = proxy.TryGetOutParameter(
+ inputNumber: expectedNumber,
+
+ out int outNumber,
+ out string outString,
+ out PerScreen<int> outReference,
+ out IDictionary<int, PerScreen<int>> outComplexType
+ );
+
+ // assert
+ result.Should().BeTrue();
+
+ outNumber.Should().Be(expectedNumber);
+
+ outString.Should().Be(expectedNumber.ToString());
+
+ outReference.Should().NotBeNull();
+ outReference.Value.Should().Be(expectedNumber);
+
+ outComplexType.Should().NotBeNull();
+ outComplexType.Count.Should().Be(1);
+ outComplexType.Keys.First().Should().Be(expectedNumber);
+ outComplexType.Values.First().Should().NotBeNull();
+ outComplexType.Values.First().Value.Should().Be(expectedNumber);
+ }
+
/*********
** Private methods
@@ -335,10 +390,10 @@ namespace SMAPI.Tests.Core
}
/// <summary>Get a proxy API instance.</summary>
+ /// <param name="proxyFactory">The proxy factory to use.</param>
/// <param name="implementation">The underlying API instance.</param>
- private ISimpleApi GetProxy(object implementation)
+ private ISimpleApi GetProxy(IInterfaceProxyFactory proxyFactory, object implementation)
{
- var proxyFactory = new InterfaceProxyFactory();
return proxyFactory.CreateProxy<ISimpleApi>(implementation, this.FromModId, this.ToModId);
}
}
diff --git a/src/SMAPI.Tests/Core/ModResolverTests.cs b/src/SMAPI.Tests/Core/ModResolverTests.cs
index bd621bbf..6b2746f5 100644
--- a/src/SMAPI.Tests/Core/ModResolverTests.cs
+++ b/src/SMAPI.Tests/Core/ModResolverTests.cs
@@ -38,6 +38,9 @@ namespace SMAPI.Tests.Core
// assert
Assert.AreEqual(0, mods.Length, 0, $"Expected to find zero manifests, found {mods.Length} instead.");
+
+ // cleanup
+ Directory.Delete(rootFolder, recursive: true);
}
[Test(Description = "Assert that the resolver correctly returns a failed metadata if there's an empty mod folder.")]
@@ -56,6 +59,9 @@ namespace SMAPI.Tests.Core
Assert.AreEqual(1, mods.Length, 0, $"Expected to find one manifest, found {mods.Length} instead.");
Assert.AreEqual(ModMetadataStatus.Failed, mod!.Status, "The mod metadata was not marked failed.");
Assert.IsNotNull(mod.Error, "The mod metadata did not have an error message set.");
+
+ // cleanup
+ Directory.Delete(rootFolder, recursive: true);
}
[Test(Description = "Assert that the resolver correctly reads manifest data from a randomized file.")]
@@ -115,6 +121,9 @@ namespace SMAPI.Tests.Core
Assert.IsNotNull(mod.Manifest.Dependencies, "The dependencies field should not be null.");
Assert.AreEqual(1, mod.Manifest.Dependencies.Length, "The dependencies field should contain one value.");
Assert.AreEqual(originalDependency[nameof(IManifestDependency.UniqueID)], mod.Manifest.Dependencies[0].UniqueID, "The first dependency's unique ID doesn't match.");
+
+ // cleanup
+ Directory.Delete(rootFolder, recursive: true);
}
/****
@@ -123,7 +132,7 @@ namespace SMAPI.Tests.Core
[Test(Description = "Assert that validation doesn't fail if there are no mods installed.")]
public void ValidateManifests_NoMods_DoesNothing()
{
- new ModResolver().ValidateManifests(Array.Empty<ModMetadata>(), apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
+ new ModResolver().ValidateManifests(Array.Empty<ModMetadata>(), apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null, validateFilesExist: false);
}
[Test(Description = "Assert that validation skips manifests that have already failed without calling any other properties.")]
@@ -134,7 +143,7 @@ namespace SMAPI.Tests.Core
mock.Setup(p => p.Status).Returns(ModMetadataStatus.Failed);
// act
- new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
+ new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null, validateFilesExist: false);
// assert
mock.VerifyGet(p => p.Status, Times.Once, "The validation did not check the manifest status.");
@@ -145,13 +154,13 @@ namespace SMAPI.Tests.Core
{
// arrange
Mock<IModMetadata> mock = this.GetMetadata("Mod A", Array.Empty<string>(), allowStatusChange: true);
- this.SetupMetadataForValidation(mock, new ModDataRecordVersionedFields(this.GetModDataRecord())
+ mock.Setup(p => p.DataRecord).Returns(() => new ModDataRecordVersionedFields(this.GetModDataRecord())
{
Status = ModStatus.AssumeBroken
});
// act
- new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
+ new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null, validateFilesExist: false);
// assert
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
@@ -163,10 +172,9 @@ namespace SMAPI.Tests.Core
// arrange
Mock<IModMetadata> mock = this.GetMetadata("Mod A", Array.Empty<string>(), allowStatusChange: true);
mock.Setup(p => p.Manifest).Returns(this.GetManifest(minimumApiVersion: "1.1"));
- this.SetupMetadataForValidation(mock);
// act
- new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
+ new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null, validateFilesExist: false);
// assert
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
@@ -176,14 +184,18 @@ namespace SMAPI.Tests.Core
public void ValidateManifests_MissingEntryDLL_Fails()
{
// arrange
- Mock<IModMetadata> mock = this.GetMetadata(this.GetManifest(id: "Mod A", version: "1.0", entryDll: "Missing.dll"), allowStatusChange: true);
- this.SetupMetadataForValidation(mock);
+ string directoryPath = this.GetTempFolderPath();
+ Mock<IModMetadata> mock = this.GetMetadata(this.GetManifest(id: "Mod A", version: "1.0", entryDll: "Missing.dll"), allowStatusChange: true, directoryPath: directoryPath);
+ Directory.CreateDirectory(directoryPath);
// act
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
// assert
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
+
+ // cleanup
+ Directory.Delete(directoryPath);
}
[Test(Description = "Assert that validation fails when multiple mods have the same unique ID.")]
@@ -192,16 +204,13 @@ namespace SMAPI.Tests.Core
// arrange
Mock<IModMetadata> modA = this.GetMetadata("Mod A", Array.Empty<string>(), allowStatusChange: true);
Mock<IModMetadata> modB = this.GetMetadata(this.GetManifest(id: "Mod A", name: "Mod B", version: "1.0"), allowStatusChange: true);
- Mock<IModMetadata> modC = this.GetMetadata("Mod C", Array.Empty<string>(), allowStatusChange: false);
- foreach (Mock<IModMetadata> mod in new[] { modA, modB, modC })
- this.SetupMetadataForValidation(mod);
// act
- new ModResolver().ValidateManifests(new[] { modA.Object, modB.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
+ new ModResolver().ValidateManifests(new[] { modA.Object, modB.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null, validateFilesExist: false);
// assert
- modA.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the first mod with a unique ID.");
- modB.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the second mod with a unique ID.");
+ modA.Verify(p => p.SetStatus(ModMetadataStatus.Failed, ModFailReason.Duplicate, It.IsAny<string>(), It.IsAny<string>()), Times.AtLeastOnce, "The validation did not fail the first mod with a unique ID.");
+ modB.Verify(p => p.SetStatus(ModMetadataStatus.Failed, ModFailReason.Duplicate, It.IsAny<string>(), It.IsAny<string>()), Times.AtLeastOnce, "The validation did not fail the second mod with a unique ID.");
}
[Test(Description = "Assert that validation fails when the manifest references a DLL that does not exist.")]
@@ -227,6 +236,9 @@ namespace SMAPI.Tests.Core
// assert
// if Moq doesn't throw a method-not-setup exception, the validation didn't override the status.
+
+ // cleanup
+ Directory.Delete(modFolder, recursive: true);
}
/****
@@ -514,14 +526,20 @@ namespace SMAPI.Tests.Core
/// <summary>Get a randomized basic manifest.</summary>
/// <param name="manifest">The mod manifest.</param>
/// <param name="allowStatusChange">Whether the code being tested is allowed to change the mod status.</param>
- private Mock<IModMetadata> GetMetadata(IManifest manifest, bool allowStatusChange = false)
+ /// <param name="directoryPath">The directory path the mod metadata should be pointed at, or <c>null</c> to generate a fake path.</param>
+ private Mock<IModMetadata> GetMetadata(IManifest manifest, bool allowStatusChange = false, string? directoryPath = null)
{
+ directoryPath ??= this.GetTempFolderPath();
+
Mock<IModMetadata> mod = new(MockBehavior.Strict);
mod.Setup(p => p.DataRecord).Returns(this.GetModDataRecordVersionedFields());
mod.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
mod.Setup(p => p.DisplayName).Returns(manifest.UniqueID);
+ mod.Setup(p => p.DirectoryPath).Returns(directoryPath);
mod.Setup(p => p.Manifest).Returns(manifest);
mod.Setup(p => p.HasID(It.IsAny<string>())).Returns((string id) => manifest.UniqueID == id);
+ mod.Setup(p => p.GetUpdateKeys(It.IsAny<bool>())).Returns(Enumerable.Empty<UpdateKey>());
+ mod.Setup(p => p.GetRelativePathWithRoot()).Returns(directoryPath);
if (allowStatusChange)
{
mod
@@ -532,18 +550,6 @@ namespace SMAPI.Tests.Core
return mod;
}
- /// <summary>Set up a mock mod metadata for <see cref="ModResolver.ValidateManifests"/>.</summary>
- /// <param name="mod">The mock mod metadata.</param>
- /// <param name="modRecord">The extra metadata about the mod from SMAPI's internal data (if any).</param>
- private void SetupMetadataForValidation(Mock<IModMetadata> mod, ModDataRecordVersionedFields? modRecord = null)
- {
- mod.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
- mod.Setup(p => p.Manifest).Returns(this.GetManifest());
- mod.Setup(p => p.DirectoryPath).Returns(Path.GetTempPath());
- mod.Setup(p => p.DataRecord).Returns(modRecord ?? this.GetModDataRecordVersionedFields());
- mod.Setup(p => p.GetUpdateKeys(It.IsAny<bool>())).Returns(Enumerable.Empty<UpdateKey>());
- }
-
/// <summary>Generate a default mod data record.</summary>
private ModDataRecord GetModDataRecord()
{