summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests.ModApiProvider/ProviderMod.cs
blob: 3fc8d749505de200aab069b3c5055531b74ea8bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#nullable disable

using System.Collections.Generic;
using System.Reflection;
using SMAPI.Tests.ModApiProvider.Framework;

namespace SMAPI.Tests.ModApiProvider
{
    /// <summary>A simulated mod instance.</summary>
    public class ProviderMod
    {
        /// <summary>The underlying API instance.</summary>
        private readonly SimpleApi Api = new();

        /// <summary>Get the mod API instance.</summary>
        public object GetModApi()
        {
            return this.Api;
        }

        /// <summary>Raise the <see cref="SimpleApi.OnEventRaised"/> event.</summary>
        /// <param name="value">The value to send as an event argument.</param>
        public void RaiseEvent(int value)
        {
            this.Api.RaiseEventField(value);
        }

        /// <summary>Set the values for the API property.</summary>
        public void SetPropertyValues(int number, object obj, string listValue, string listWithInterfaceValue, string dictionaryKey, string dictionaryListValue, BindingFlags enumValue, string inheritedValue)
        {
            this.Api.NumberProperty = number;
            this.Api.ObjectProperty = obj;
            this.Api.ListProperty = new List<string> { listValue };
            this.Api.ListPropertyWithInterface = new List<string> { listWithInterfaceValue };
            this.Api.GenericsProperty = new Dictionary<string, IList<string>> { [dictionaryKey] = new List<string> { dictionaryListValue } };
            this.Api.EnumProperty = enumValue;
            this.Api.InheritedProperty = inheritedValue;
        }
    }
}