Skip to content

Instantly share code, notes, and snippets.

@object
Created May 17, 2013 12:06
Show Gist options
  • Save object/5598634 to your computer and use it in GitHub Desktop.
Save object/5598634 to your computer and use it in GitHub Desktop.
C# dynamic test for iOS
using System.Dynamic;
using NUnit.Framework;
namespace DynamicTest
{
public class TestObject : DynamicObject
{
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (binder.Name == "MeaningOfLife")
{
result = 42;
return true;
}
return base.TryGetMember(binder, out result);
}
}
[TestFixture]
public class Test
{
[Test]
public void GetMember()
{
dynamic obj = new TestObject();
Assert.AreEqual(42, obj.MeaningOfLife);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment