using System; using SMAPI.Tests.ModApiConsumer.Interfaces; namespace SMAPI.Tests.ModApiConsumer { /// A simulated API consumer. public class ApiConsumer { /********* ** Public methods *********/ /// Call the event field on the given API. /// The API to call. /// Get the number of times the event was called and the last value received. public void UseEventField(ISimpleApi api, out Func<(int timesCalled, int actualValue)> getValues) { // act int calls = 0; int lastValue = -1; api.OnEventRaised += (sender, value) => { calls++; lastValue = value; }; getValues = () => (timesCalled: calls, actualValue: lastValue); } /// Call the event property on the given API. /// The API to call. /// Get the number of times the event was called and the last value received. public void UseEventProperty(ISimpleApi api, out Func<(int timesCalled, int actualValue)> getValues) { // act int calls = 0; int lastValue = -1; api.OnEventRaisedProperty += (sender, value) => { calls++; lastValue = value; }; getValues = () => (timesCalled: calls, actualValue: lastValue); } } }