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; IRetweetService service = testServer.Host.Services.GetService(typeof(IRetweetService)) as IRetweetService; var model = new ApiRetweetServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00"), 1); CreateResponse <ApiRetweetServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.RetweetDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiRetweetServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); var mapper = new ApiRetweetServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IRetweetService service = testServer.Host.Services.GetService(typeof(IRetweetService)) as IRetweetService; ApiRetweetServerResponseModel model = await service.Get(1); ApiRetweetClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00"), 1); UpdateResponse <ApiRetweetClientResponseModel> updateResponse = await client.RetweetUpdateAsync(model.Id, request); context.Entry(context.Set <Retweet>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Retweet>().ToList()[0].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Retweet>().ToList()[0].RetwitterUserId.Should().Be(1); context.Set <Retweet>().ToList()[0].Time.Should().Be(TimeSpan.Parse("02:00:00")); context.Set <Retweet>().ToList()[0].TweetTweetId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.RetwitterUserId.Should().Be(1); updateResponse.Record.Time.Should().Be(TimeSpan.Parse("02:00:00")); updateResponse.Record.TweetTweetId.Should().Be(1); }