public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ICommentService service = testServer.Host.Services.GetService(typeof(ICommentService)) as ICommentService; var model = new ApiCommentServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 2, "B", 1); CreateResponse <ApiCommentServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.CommentDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiCommentServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiCommentServerModelMapper(); var model = new ApiCommentServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", 1); ApiCommentServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.PostId.Should().Be(1); response.Score.Should().Be(1); response.Text.Should().Be("A"); response.UserId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiCommentServerModelMapper(); var model = new ApiCommentServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", 1); JsonPatchDocument <ApiCommentServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiCommentServerRequestModel(); patch.ApplyTo(response); response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.PostId.Should().Be(1); response.Score.Should().Be(1); response.Text.Should().Be("A"); response.UserId.Should().Be(1); }