public void CommentPost_WhenSessionKeyIsNotCorrect_ShouldReturnStatusCode400() { var user = new User() { DisplayName = "JavaScript", Username = "******", AuthCode = "bfff2dd4f1b310eb0dbf593bd83f94dd8d34077e", SessionKey = "1zIzcHNYWhSKnWVrGNpBLxOzDDLPRMbHMeMjklumYmodzRTgAH" }; var fakeUserRepo = new FakeUserRepository(); fakeUserRepo.Add(user); var post = new Post() { PostDate = DateTime.Now, Text = "Some text", Title = "SomeTitle", User = user }; var fakePostRepo = new FakePostRepository(); fakePostRepo.Add(post); var server = new InMemoryHttpServer <Post>("http://localhost/", fakePostRepo); var response = server.CreateGetRequest("api/posts?sessionKey=1zIzcHNYWhSKnWVrGNpBLxOzDDLPRMbHMeMjklumYmodzRTgAH&tags"); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
public void GetByTags_WhenTagsAreNotCorrect_ShouldReturnNoContent() { var user = new User() { DisplayName = "JavaScript", Username = "******", AuthCode = "bfff2dd4f1b310eb0dbf593bd83f94dd8d34077e", SessionKey = "1zIzcHNYWhSKnWVrGNpBLxOzDDLPRMbHMeMjklumYmodzRTgAH" }; var fakeUserRepo = new FakeUserRepository(); fakeUserRepo.Add(user); var post = new Post() { PostDate = DateTime.Now, Text = "Some text", Title = "SomeTitle", User = user }; var fakePostRepo = new FakePostRepository(); fakePostRepo.Add(post); var tags = new List <Tag>() { new Tag() { Name = "c#", Posts = new List <Post>() { post } }, new Tag() { Name = "web", Posts = new List <Post>() { post } }, }; var fakeTagRepo = new FakeTagRepository(); fakeTagRepo.Add(tags[0]); fakeTagRepo.Add(tags[1]); var server = new InMemoryHttpServer <Post>("http://localhost/", fakePostRepo); var response = server.CreateGetRequest("api/posts?sessionKey=1zIzcHNYWhSKnWVrGNpBLxOzDDLPRMbHMeMjklumYmodzRTgAH&tags=js"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); }