Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created June 7, 2010 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenharman/428821 to your computer and use it in GitHub Desktop.
Save stevenharman/428821 to your computer and use it in GitHub Desktop.
public class when_creating_a_doodad
{
private dynamic _result;
protected override void context()
{
var controller = new DoodadController();
// create action returns a JsonResult w/the an Anonymous object containing the associated Thingy's Id.
_result = controller.Create(new DoodadCreateCommand { title = "i'm new!" });
}
[Specification]
public void it_has_a_default_thingy_id()
{
_result.Data.thingyId.should_equal(12L);
// this blows up with the following exception:
// Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'long' does not contain a definition for 'should_equal'
// at CallSite.Target(Closure , CallSite , Object , Int64 )
// at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
}
}
@stevehorn
Copy link

((long)_result.Data.thingyId).should_equal(12L);

@stevenharman
Copy link
Author

yeah, that would work, but its

  1. obtuse
    b. annoying
    iii- kinda defeats the purpose

@stevehorn
Copy link

Thinking this is still a step up from matching on a Json string, which is what I have been doing:
http://blog.stevehorn.cc/2010/04/how-to-test-aspnet-mvc-jsonresult.html

Are there any other alternatives?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment