Skip to content

Instantly share code, notes, and snippets.

@agross
Created February 14, 2010 15:57
Show Gist options
  • Save agross/304102 to your computer and use it in GitHub Desktop.
Save agross/304102 to your computer and use it in GitHub Desktop.
using System.Dynamic;
using Machine.Specifications;
namespace ClassLibrary1
{
public class DynamicClass
{
public dynamic DoSomething()
{
dynamic foo = new ExpandoObject();
foo.Bar = "baz";
return foo;
}
}
public class When_Context
{
static DynamicClass Sut;
static dynamic Result;
Establish context = () => { Sut = new DynamicClass(); };
Because of = () => { Result = Sut.DoSomething(); };
It should_ = () => Result.Bar.ShouldEqual("baz");
}
}
using ClassLibrary1;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
DynamicClass Sut;
dynamic Result;
Sut = new DynamicClass();
Result = Sut.DoSomething();
Assert.AreEqual(Result.Bar, "baz");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment