Created
May 17, 2013 12:06
-
-
Save object/5598634 to your computer and use it in GitHub Desktop.
C# dynamic test for iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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