31 lines
1.4 KiB
C#

using Mocha.Core.Oop;
using Mocha.Core.Oop.Methods;
namespace Mocha.Core.Tests.MethodTests;
public class SystemRoutineTests : MethodTestsBase
{
private Guid TEST_SYSTEM_ATTRIBUTE_ROUTINE_GUID = new Guid("{fd726a89-86b3-46ea-b65b-20681358ea92}");
private string TEST_SYSTEM_ATTRIBUTE_ROUTINE_VALUE = "Picadilly Circus";
[Test]
public void GetAttributeBySystemRoutineTest()
{
InstanceHandle irTestClass = Oms.GetInstance(TEST_CLASS_GUID);
OmsMethodBuilder methodBuilder = new OmsMethodBuilder(Oms);
OmsSystemRoutineBuilder systemRoutineBuilder = new OmsSystemRoutineBuilder(Oms);
SystemAttributeRoutine<string> testSystemAttributeRoutine = systemRoutineBuilder.CreateSystemAttributeRoutine(TEST_SYSTEM_ATTRIBUTE_ROUTINE_GUID, delegate ()
{
return TEST_SYSTEM_ATTRIBUTE_ROUTINE_VALUE;
});
GetAttributeBySystemRoutineMethod gasMethod = methodBuilder.CreateGetAttributeBySystemRoutineMethod(irTestClass, "get", "Test System Routine Text Attribute", AccessModifier.Public, true, Oms.GetInstance(KnownAttributeGuids.Text.Value), testSystemAttributeRoutine);
ReturnAttributeMethodBinding gasMethodRamb = methodBuilder.CreateReturnAttributeMethodBinding(gasMethod);
OmsContext context = Oms.CreateContext();
string value = Oms.ExecuteReturningAttributeValue<string>(context, gasMethodRamb);
Assert.That(value, Is.EqualTo(TEST_SYSTEM_ATTRIBUTE_ROUTINE_VALUE));
}
}