Skip to content

Instantly share code, notes, and snippets.

View pedroreys's full-sized avatar

Pedro Reys pedroreys

View GitHub Profile
[TestFixtureSetUp]
public void Setup()
{
MvcApplication.RegisterRoutes(RouteTable.Routes);
}
[Test]
public void Should_map_People_url_to_people_with_default_action()
{
"~/people".Route().ShouldMapTo<PeopleController>(x => x.Index());
public interface IApiResource
{
void SetLocation(ResourceLocation location);
}
public class ResourceLocation
{
public Uri Location { get; private set; }
public class Contact : IApiResource
{
public int Id { get; set; }
// ... other Contact Members
public SetLocation(ResourceLocation location)
{
location.Location = new Uri("http://api.contoso.com/contacts/"+Id);
}
}
public SetLocation(ResourceLocation location)
{
location.SetIn<ContactsController>(x => x.Get(Id));
}
public string Route(
string routeName,
IDictionary<string, Object> routeValues
)
System.NotSupportedException was caught
Message=This operation is only supported by directly calling it on 'RouteCollection'.
Source=System.Web.Http.WebHost
StackTrace:
at System.Web.Http.WebHost.Routing.HostedHttpRouteCollection.GetEnumerator()
at WebApiContrib.Internal.RoutingHelper.GetUriFor(RouteValueDictionary routeValues, HttpControllerContext controllerContext) in C:\dev\WebAPIContrib\src\WebApiContrib\Internal\RoutingHelper.cs:line 42
InnerException:
public HttpResponseMessage<Contact> Post(Contact contact)
{
this.repository.Post(contact);
return new CreateResponse<Contact>(contact, this.ControllerContext);
}
@pedroreys
pedroreys / gist:2173894
Created March 23, 2012 19:05
WebAPIContrib Transitions
public interface IApiResource {
void SetLocation(ResourceLocation resourceLocation);
void SetTransitions(ResourceTransitions transitions);
}
public class Order : IApiResource {
public int Id { get; set; }
// other resource members ...
@pedroreys
pedroreys / gist:2229376
Created March 28, 2012 18:51
aspnetwebstack build log
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.261]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
System.Web.Razor -> C:\dev\aspnetwebstack\bin\Release\System.Web.Razor.dll
System.Web.WebPages.Deployment -> C:\dev\aspnetwebstack\bin\Release\System.Web.WebPages.Deployment.dll
WebMatrix.Data -> C:\dev\aspnetwebstack\bin\Release\WebMatrix.Data.dll
Microsoft.TestCommon -> C:\dev\aspnetwebstack\bin\Release\Test\Microsoft.TestCommon.dll
System.Json -> C:\dev\aspnetwebstack\bin\Release\System.Json.dll
System.Net.Http.Formatting -> C:\dev\aspnetwebstack\bin\Release\System.Net.Http.Formatting.dll
@pedroreys
pedroreys / gist:2229908
Created March 28, 2012 19:48
strong name log
Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly/Strong Name Users
===========================================
Microsoft.TestCommon,31bf3856ad364e35 All users
Microsoft.Web.Helpers,31bf3856ad364e35 All users
Microsoft.Web.Helpers.Test,31bf3856ad364e35 All users
Microsoft.Web.Http.Data,31bf3856ad364e35 All users