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 ApiLinkLogServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ILinkLogService service = testServer.Host.Services.GetService(typeof(ILinkLogService)) as ILinkLogService; ApiLinkLogServerResponseModel model = await service.Get(1); ApiLinkLogClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B"); UpdateResponse <ApiLinkLogClientResponseModel> updateResponse = await client.LinkLogUpdateAsync(model.Id, request); context.Entry(context.Set <LinkLog>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <LinkLog>().ToList()[0].DateEntered.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <LinkLog>().ToList()[0].LinkId.Should().Be(1); context.Set <LinkLog>().ToList()[0].Log.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.DateEntered.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.LinkId.Should().Be(1); updateResponse.Record.Log.Should().Be("B"); }
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; ILinkLogService service = testServer.Host.Services.GetService(typeof(ILinkLogService)) as ILinkLogService; var model = new ApiLinkLogServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B"); CreateResponse <ApiLinkLogServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.LinkLogDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiLinkLogServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }