summaryrefslogtreecommitdiff
path: root/src/SMAPI.Tests.ModApiProvider/ProviderMod.cs
blob: c36e1c6dd67ae6dae7b888b522423eaaa260cd37 (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
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;
        }
    }
}