public void TestInitialize() { // Needed to load the assemlies of Services project UsersController usersController = new UsersController(); transactionScope = new TransactionScope(); var routes = new List<Route>() { new Route( "UsersApi", "api/users/{action}", new { controller = "users" }) }; this.httpServer = new InMemoryHttpServer("http://localhost/", routes); }
public void TestInitialize() { // Needed to load the assemlies of Services project PostsController postsController = new PostsController(); transactionScope = new TransactionScope(); var routes = new List<Route>() { new Route( "PostsApi", "api/posts/{postID}/{action}", new { controller = "posts", postID = RouteParameter.Optional, action = RouteParameter.Optional }), new Route( "UsersApi", "api/users/{action}", new { controller = "users" }) }; this.httpServer = new InMemoryHttpServer("http://localhost/", routes); // Register a user and user his session key for tests var testUser = new UserRegisterModel() { DisplayName = "Pesho Peshov", Username = "******", AuthCode = "bfff2dd4f1b310eb0dbf593bd83f94dd8d34077e" }; var httpResponse = this.httpServer.Post("api/users/register", testUser); var loggedUserModel = httpResponse.Content.ReadAsAsync<UserLoggedModel>().Result; this.sessionKeyHeader = new Dictionary<string, string>(); this.sessionKeyHeader["X-sessionKey"] = loggedUserModel.SessionKey; }
public void TestInit() { var type = typeof(PostsController); tran = new TransactionScope(); var routes = new List<Route> { new Route( "TagsApi", "api/tags/{tagId}/posts", new { controller = "tags", action = "posts"} ), new Route( "PostsApi", "api/posts/{postId}/comment", new { controller = "posts", action = "comment"} ), 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); var testUser = new UserModel() { Username = "******", DisplayName = "validdisplayname", AuthCode = new string('b', 40) }; var response = this.httpServer.Post("api/users/register", testUser); var contentString = response.Content.ReadAsStringAsync().Result; var userModel = JsonConvert.DeserializeObject<LoggedUserModel>(contentString); this.validUser = userModel; }
public void TestInit() { var type = typeof(PostsController); tran = new TransactionScope(); var routes = new List<Route> { new Route( "TagsApi", "api/tags/{tagId}/posts", new { controller = "tags", action = "posts"} ), new Route( "PostsApi", "api/posts/{postId}/comment", new { controller = "posts", action = "comment"} ), 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); }