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; IQuoteTweetService service = testServer.Host.Services.GetService(typeof(IQuoteTweetService)) as IQuoteTweetService; var model = new ApiQuoteTweetServerRequestModel(); model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, TimeSpan.Parse("02:00:00")); CreateResponse <ApiQuoteTweetServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.QuoteTweetDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiQuoteTweetServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiQuoteTweetServerModelMapper(); var model = new ApiQuoteTweetServerRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, TimeSpan.Parse("01:00:00")); ApiQuoteTweetServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.RetweeterUserId.Should().Be(1); response.SourceTweetId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("01:00:00")); }
public void CreatePatch() { var mapper = new ApiQuoteTweetServerModelMapper(); var model = new ApiQuoteTweetServerRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, TimeSpan.Parse("01:00:00")); JsonPatchDocument <ApiQuoteTweetServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiQuoteTweetServerRequestModel(); patch.ApplyTo(response); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.RetweeterUserId.Should().Be(1); response.SourceTweetId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("01:00:00")); }