Пример #1
0
        private UserLoggedModel RegisterTestUser(InMemoryHttpServer httpServer, UserModel testUser)
        {
            var response      = httpServer.Post("api/users/register", testUser);
            var contentString = response.Content.ReadAsStringAsync().Result;
            var userModel     = JsonConvert.DeserializeObject <UserLoggedModel>(contentString);

            return(userModel);
        }
        public void TestInit()
        {
            var type = typeof(PostsController);

            tran = new TransactionScope();

            var routes = new List <Route>
            {
                new Route(
                    "PostsApi",
                    "api/posts/{postId}/comment",
                    new
                {
                    controller = "posts",
                    action     = "comment"
                }),
                new Route(
                    "TagsApi",
                    "api/tags/{tagId}/posts",
                    new
                {
                    controller = "tags",
                    action     = "posts"
                }),
                new Route(
                    "UsertApi",
                    "api/users/{action}",
                    new { controller = "users" }),
                new Route(
                    "DefaultApi",
                    "api/{controller}/{id}",
                    new { id = RouteParameter.Optional }),
            };

            this.httpServer = new InMemoryHttpServer("http://localhost/", routes);
        }