summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-16 16:59:53 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-16 16:59:53 -0400
commit20224d293d03d34860505980cabdb4bc5cf13319 (patch)
tree36e9e6da9abe939e7f84f6c42b7a4d9cb703eec3 /src/SMAPI.Tests
parent559d763756e3ccbd7feaa3b82d7924d8cd97969f (diff)
downloadSMAPI-20224d293d03d34860505980cabdb4bc5cf13319.tar.gz
SMAPI-20224d293d03d34860505980cabdb4bc5cf13319.tar.bz2
SMAPI-20224d293d03d34860505980cabdb4bc5cf13319.zip
add unit test for proxied out parameters
Diffstat (limited to 'src/SMAPI.Tests')
-rw-r--r--src/SMAPI.Tests/Core/InterfaceProxyTests.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/SMAPI.Tests/Core/InterfaceProxyTests.cs b/src/SMAPI.Tests/Core/InterfaceProxyTests.cs
index 0b4919ed..8d27f6af 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
{
@@ -308,6 +310,43 @@ namespace SMAPI.Tests.Core
actualValue.Should().BeSameAs(expectedValue);
}
+ /// <summary>Assert that a method with out parameters can be proxied correctly.</summary>
+ [Test]
+ [SuppressMessage("ReSharper", "ConvertToLocalFunction")]
+ public void CanProxy_Method_OutParameters()
+ {
+ // arrange
+ object implementation = new ProviderMod().GetModApi();
+ const int expectedNumber = 42;
+
+ // act
+ ISimpleApi proxy = this.GetProxy(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