public void TestInit()
        {
            var type = typeof(PostsController);
            tran = new TransactionScope();

            var routes = new List<Route>
            {
                new Route(
                    "PutCommentsApi",
                    "api/posts/{postId}/comment",
                    new
                    {
                        controller = "posts",
                        action = "PutComment"
                    }),
                new Route(
                    "UsersApi",
                    "api/users/{action}",
                    new
                    {
                        controller = "users"
                    }),

                new Route(
                    "DefaultApi",
                    "api/{controller}/{id}",
                    new {id = RouteParameter.Optional}),
            };
            this.httpServer = new InMemoryHttpServer("http://localhost/", routes);
        }
Ejemplo n.º 2
0
 public static LoggedUserModel RegisterTestValidUser(InMemoryHttpServer httpServer, UserModel testUser)
 {
     var response = httpServer.Post("api/users/register", testUser);
     var contentString = response.Content.ReadAsStringAsync().Result;
     var userModel = JsonConvert.DeserializeObject<LoggedUserModel>(contentString);
     return userModel;
 }