public async Task Publication_NotFound() { // Setup var userId = Guid.Parse("B4E69138-CE54-444A-8226-2CFABFD352C6"); var publicationId = Guid.NewGuid().ToString(); NewsFeedStorageMock .Setup(s => s.GetByIdAsync(publicationId)) .ReturnsAsync(default(NewsFeedPublication)); CurrentUserProviderMock .Setup(s => s.UserId) .Returns(userId.ToString()); var client = TestServerHelper.New(collection => { collection.AddAuthentication("Test") .AddScheme <AuthenticationSchemeOptions, TestAuthHandler>("Test", _ => { }); collection.AddScoped(_ => NewsFeedStorageMock.Object); collection.AddScoped(_ => CurrentUserProviderMock.Object); }); var input = new CreateNewsFeedPublication { Content = "123" }; // Act var response = await client.PutAsync($"/newsfeed/{publicationId}", input.AsJsonContent()); // Assert Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); }
public async Task Comment_BadRequest() { // Setup var userId = Guid.Parse("B4E69138-CE54-444A-8226-2CFABFD352C6"); var publicationId = Guid.NewGuid().ToString(); var commentId = Guid.NewGuid().ToString(); const string oldContent = "Old Content"; string newContent = string.Empty; NewsFeedCommentsStorageMock .Setup(s => s.GetByIdAsync(commentId)) .ReturnsAsync( new PublicationComment( commentId, oldContent, publicationId, new UserInfo(userId, string.Empty, null), DateTimeOffset.Now)); NewsFeedCommentsStorageMock .Setup(s => s.UpdateAsync(commentId, newContent)) .ThrowsAsync(new ApiException { ErrorCode = (int)HttpStatusCode.BadRequest }); CurrentUserProviderMock .Setup(s => s.UserId) .Returns(userId.ToString()); var client = TestServerHelper.New(collection => { collection.AddAuthentication("Test") .AddScheme <AuthenticationSchemeOptions, TestAuthHandler>("Test", _ => { }); collection.AddScoped(_ => NewsFeedStorageMock.Object); collection.AddScoped(_ => CurrentUserProviderMock.Object); }); var input = new UpdateNewsFeedComment { Content = newContent }; // Act var response = await client.PutAsync($"/newsfeed/comments/{commentId}", input.AsJsonContent()); // Assert Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }