Created
June 7, 2010 15:44
-
-
Save stevenharman/428821 to your computer and use it in GitHub Desktop.
This file contains 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
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) | |
} | |
} |
yeah, that would work, but its
- obtuse
b. annoying
iii- kinda defeats the purpose
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
((long)_result.Data.thingyId).should_equal(12L);