public virtual async void TestBulkInsert() { 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; var model = new ApiCallClientRequestModel(); model.SetProperties(1, 1, 1, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), 2); var model2 = new ApiCallClientRequestModel(); model2.SetProperties(1, 1, 1, "C", 1, DateTime.Parse("1/1/1989 12:00:00 AM"), DateTime.Parse("1/1/1989 12:00:00 AM"), DateTime.Parse("1/1/1989 12:00:00 AM"), 3); var request = new List <ApiCallClientRequestModel>() { model, model2 }; CreateResponse <List <ApiCallClientResponseModel> > result = await client.CallBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Call>().ToList()[1].AddressId.Should().Be(1); context.Set <Call>().ToList()[1].CallDispositionId.Should().Be(1); context.Set <Call>().ToList()[1].CallStatusId.Should().Be(1); context.Set <Call>().ToList()[1].CallString.Should().Be("B"); context.Set <Call>().ToList()[1].CallTypeId.Should().Be(1); context.Set <Call>().ToList()[1].DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Call>().ToList()[1].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Call>().ToList()[1].DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Call>().ToList()[1].QuickCallNumber.Should().Be(2); context.Set <Call>().ToList()[2].AddressId.Should().Be(1); context.Set <Call>().ToList()[2].CallDispositionId.Should().Be(1); context.Set <Call>().ToList()[2].CallStatusId.Should().Be(1); context.Set <Call>().ToList()[2].CallString.Should().Be("C"); context.Set <Call>().ToList()[2].CallTypeId.Should().Be(1); context.Set <Call>().ToList()[2].DateCleared.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM")); context.Set <Call>().ToList()[2].DateCreated.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM")); context.Set <Call>().ToList()[2].DateDispatched.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM")); context.Set <Call>().ToList()[2].QuickCallNumber.Should().Be(3); }
public virtual ApiCallClientRequestModel MapServerResponseToClientRequest( ApiCallServerResponseModel response) { var request = new ApiCallClientRequestModel(); request.SetProperties( response.AddressId, response.CallDispositionId, response.CallStatusId, response.CallString, response.CallTypeId, response.DateCleared, response.DateCreated, response.DateDispatched, response.QuickCallNumber); return(request); }
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 ApiCallServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ICallService service = testServer.Host.Services.GetService(typeof(ICallService)) as ICallService; ApiCallServerResponseModel model = await service.Get(1); ApiCallClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, 1, 1, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), 2); UpdateResponse <ApiCallClientResponseModel> updateResponse = await client.CallUpdateAsync(model.Id, request); context.Entry(context.Set <Call>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Call>().ToList()[0].AddressId.Should().Be(1); context.Set <Call>().ToList()[0].CallDispositionId.Should().Be(1); context.Set <Call>().ToList()[0].CallStatusId.Should().Be(1); context.Set <Call>().ToList()[0].CallString.Should().Be("B"); context.Set <Call>().ToList()[0].CallTypeId.Should().Be(1); context.Set <Call>().ToList()[0].DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Call>().ToList()[0].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Call>().ToList()[0].DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Call>().ToList()[0].QuickCallNumber.Should().Be(2); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.AddressId.Should().Be(1); updateResponse.Record.CallDispositionId.Should().Be(1); updateResponse.Record.CallStatusId.Should().Be(1); updateResponse.Record.CallString.Should().Be("B"); updateResponse.Record.CallTypeId.Should().Be(1); updateResponse.Record.DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.QuickCallNumber.Should().Be(2); }
public void MapClientResponseToRequest() { var mapper = new ApiCallModelMapper(); var model = new ApiCallClientResponseModel(); model.SetProperties(1, 1, 1, 1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1); ApiCallClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.AddressId.Should().Be(1); response.CallDispositionId.Should().Be(1); response.CallStatusId.Should().Be(1); response.CallString.Should().Be("A"); response.CallTypeId.Should().Be(1); response.DateCleared.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.DateDispatched.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.QuickCallNumber.Should().Be(1); }