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 ApiCallPersonServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ICallPersonService service = testServer.Host.Services.GetService(typeof(ICallPersonService)) as ICallPersonService; ApiCallPersonServerResponseModel model = await service.Get(1); ApiCallPersonClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", 1, 1); UpdateResponse <ApiCallPersonClientResponseModel> updateResponse = await client.CallPersonUpdateAsync(model.Id, request); context.Entry(context.Set <CallPerson>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <CallPerson>().ToList()[0].Note.Should().Be("B"); context.Set <CallPerson>().ToList()[0].PersonId.Should().Be(1); context.Set <CallPerson>().ToList()[0].PersonTypeId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Note.Should().Be("B"); updateResponse.Record.PersonId.Should().Be(1); updateResponse.Record.PersonTypeId.Should().Be(1); }
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; ICallPersonService service = testServer.Host.Services.GetService(typeof(ICallPersonService)) as ICallPersonService; var model = new ApiCallPersonServerRequestModel(); model.SetProperties("B", 1, 1); CreateResponse <ApiCallPersonServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.CallPersonDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiCallPersonServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public CallPersonController( ApiSettings settings, ILogger <CallPersonController> logger, ITransactionCoordinator transactionCoordinator, ICallPersonService callPersonService, IApiCallPersonServerModelMapper callPersonModelMapper ) : base(settings, logger, transactionCoordinator) { this.CallPersonService = callPersonService; this.CallPersonModelMapper = callPersonModelMapper; this.BulkInsertLimit = 250; this.MaxLimit = 1000; this.DefaultLimit = 250; }