Beispiel #1
0
 public void ByUserShouldNotResolveWithoutUsername()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Comments/ByUser")
     .WithHttpMethod(HttpMethod.Get)
     .ToInvalidModelState();
 }
Beispiel #2
0
 public void ToShouldThrowExceptionWithNotResolvedRoute()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/GetMethod")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.GetMethod());
 }
Beispiel #3
0
 public void NonExistendRouteShouldThrowProperErrorException()
 {
     MyWebApi
     .Routes()
     .ShouldMap("/Route/PostMethodWithModel")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.VoidAction());
 }
Beispiel #4
0
 public void TestRouteToNotMapPutMethodToBugsWithoutId()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/bugs")
     .WithHttpMethod(HttpMethod.Put)
     .ToNotAllowedMethod();
 }
Beispiel #5
0
 public void ToShouldResolveCorrectlyWithFullQueryString()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/QueryString?first=test&second=5")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.QueryString("test", 5));
 }
Beispiel #6
0
 public void GetAllShouldThrowExceptionWithRouteDoesNotExistWhenControllerIsInvalid()
 {
     MyWebApi
     .Routes()
     .ShouldMap(GET_PATH)
     .WithHttpMethod(HttpMethod.Get)
     .To <AircraftsController>(a => a.All());
 }
Beispiel #7
0
 public void ImagesGetShouldMapToCorrectMethod()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Images")
     .WithHttpMethod(HttpMethod.Get)
     .To <ImagesController>(c => c.Get());
 }
 public void ToShouldResolveCorrectyWithNullJsonContent()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/PostMethodWithModel")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.PostMethodWithModel(null));
 }
 public void WithHttpRequestMessageShouldWorkCorrectly()
 {
     MyWebApi
     .Routes()
     .ShouldMap(new HttpRequestMessage(HttpMethod.Post, "api/NoParameterlessConstructor/OkAction"))
     .WithHttpMethod(HttpMethod.Post)
     .To <NoParameterlessConstructorController>(c => c.OkAction());
 }
 public void ToShouldResolveCorrectlyWithRoutePrefixAndRouteAttribute()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Routes/Test")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.WithRouteAttribute());
 }
 public void ToShouldResolveCorrectlyWithIgnoredParameter()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/WithParameter/5")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.WithParameter(With.Any <int>()));
 }
 public void ToShouldResolveCorrectControllerAndActionWithActionNameAttribute()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/ChangedActionName")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.WithActionNameAttribute());
 }
 public void ToShouldResolveCorrectControllerAndActionWithUriLocation()
 {
     MyWebApi
     .Routes()
     .ShouldMap(new Uri("api/NoParameterlessConstructor/OkAction", UriKind.RelativeOrAbsolute))
     .WithHttpMethod(HttpMethod.Post)
     .To <NoParameterlessConstructorController>(c => c.OkAction());
 }
 public void ToControllerTypeShouldThrowExceptionWithIncorrectControllerType()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/NoParameterlessConstructor/OkAction")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>();
 }
 public void TestDeleteCategoryShouldMapCorrectly()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/categories/1")
     .WithHttpMethod(HttpMethod.Delete)
     .To <CategoriesController>(c => c.Delete(1));
 }
 public void ToNotAllowedMethodShouldWorkCorrectly()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/GetMethod")
     .WithHttpMethod("POST")
     .ToNotAllowedMethod();
 }
Beispiel #17
0
 public void GetAllShouldThrowExceptionWithRouteDoesNotExistWhenActionIsInvalid()
 {
     MyWebApi
     .Routes()
     .ShouldMap(GET_PATH_WITH_INVALID_ACTION)
     .WithHttpMethod(HttpMethod.Get)
     .To <AirportsController>(a => a.All());
 }
 public void ToNotAllowedMethodShouldThrowExceptionWithWrongMethod()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/GetMethod")
     .WithHttpMethod("GET")
     .ToNotAllowedMethod();
 }
Beispiel #19
0
 public void GetAllShouldMapCorrectAction()
 {
     MyWebApi
     .Routes()
     .ShouldMap(GET_PATH)
     .WithHttpMethod(HttpMethod.Get)
     .To <AirportsController>(a => a.All());
 }
 public void ToNotAllowedMethodShouldThrowExceptionWithUnresolvedRoute()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/SameAction")
     .WithHttpMethod("POST")
     .ToNotAllowedMethod();
 }
Beispiel #21
0
 public void ImageDeletionShouldMapToCorrectMethod()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Images/3")
     .WithHttpMethod(HttpMethod.Delete)
     .To <ImagesController>(c => c.Delete(3));
 }
 public void ToShouldResolveCorrectControllerAndAction()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/NoParameterlessConstructor/OkAction")
     .WithHttpMethod(HttpMethod.Post)
     .To <NoParameterlessConstructorController>(c => c.OkAction());
 }
Beispiel #23
0
 public void ToShouldResolveCorrectlyWithParameterAndQueryString()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/WithParameterAndQueryString/5?value=test")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.WithParameterAndQueryString(5, "test"));
 }
 public void WithRequestHeaderMultipleValuesShouldWorkCorrectly()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/HeaderRoute")
     .WithRequestHeader(CustomHeader, new[] { CustomHeaderValue })
     .To <RouteController>(c => c.HeaderRoute());
 }
Beispiel #25
0
 public void ToShouldResolveCorrectlyWithVoidAction()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/VoidAction")
     .WithHttpMethod(HttpMethod.Post)
     .To <RouteController>(c => c.VoidAction());
 }
 public void ToActionShouldThrowExceptionWithIncorrectAction()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/NoParameterlessConstructor/OkAction")
     .WithHttpMethod(HttpMethod.Post)
     .ToAction("Invalid");
 }
Beispiel #27
0
 public void WithCustomConfigurationShouldWorkCorrectly()
 {
     MyWebApi
     .Routes(TestObjectFactory.GetHttpConfigurationWithRoutes())
     .ShouldMap("api/NoParameterlessConstructor/OkAction")
     .WithHttpMethod(HttpMethod.Post)
     .To <NoParameterlessConstructorController>(c => c.OkAction());
 }
 public void ToControllerShouldResolveCorrectController()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/NoParameterlessConstructor/OkAction")
     .WithHttpMethod(HttpMethod.Post)
     .ToController("NoParameterlessConstructor");
 }
Beispiel #29
0
 public void ToShouldThrowExceptionWithMoreParameters()
 {
     MyWebApi
     .Routes()
     .ShouldMap("api/Route/GetMethod")
     .WithHttpMethod(HttpMethod.Get)
     .To <RouteController>(c => c.GetMethod(1));
 }
Beispiel #30
0
 public void DeleteShouldBeMappedCorrectly()
 {
     MyWebApi
     .Routes()
     .ShouldMap("/api/Categories/1")
     .WithHttpMethod(HttpMethod.Delete)
     .To <CategoriesController>(c => c.DeleteCategory(1));
 }