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 ApiSaleServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ISaleService service = testServer.Host.Services.GetService(typeof(ISaleService)) as ISaleService; ApiSaleServerResponseModel model = await service.Get(1); ApiSaleClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(2, DateTime.Parse("1/1/1988 12:00:00 AM")); UpdateResponse <ApiSaleClientResponseModel> updateResponse = await client.SaleUpdateAsync(model.Id, request); context.Entry(context.Set <Sale>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Sale>().ToList()[0].CustomerId.Should().Be(2); context.Set <Sale>().ToList()[0].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.CustomerId.Should().Be(2); updateResponse.Record.Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); }
public virtual async void TestCreate() { 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 ApiSaleClientRequestModel(); model.SetProperties(2m, 2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2); CreateResponse <ApiSaleClientResponseModel> result = await client.SaleCreateAsync(model); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Sale>().ToList()[1].Amount.Should().Be(2m); context.Set <Sale>().ToList()[1].CutomerId.Should().Be(2); context.Set <Sale>().ToList()[1].Note.Should().Be("B"); context.Set <Sale>().ToList()[1].PetId.Should().Be(1); context.Set <Sale>().ToList()[1].SaleDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Sale>().ToList()[1].SalesPersonId.Should().Be(2); result.Record.Amount.Should().Be(2m); result.Record.CutomerId.Should().Be(2); result.Record.Note.Should().Be("B"); result.Record.PetId.Should().Be(1); result.Record.SaleDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); result.Record.SalesPersonId.Should().Be(2); }
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 ApiSaleClientRequestModel(); model.SetProperties(2, DateTime.Parse("1/1/1988 12:00:00 AM")); var model2 = new ApiSaleClientRequestModel(); model2.SetProperties(3, DateTime.Parse("1/1/1989 12:00:00 AM")); var request = new List <ApiSaleClientRequestModel>() { model, model2 }; CreateResponse <List <ApiSaleClientResponseModel> > result = await client.SaleBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Sale>().ToList()[1].CustomerId.Should().Be(2); context.Set <Sale>().ToList()[1].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Sale>().ToList()[2].CustomerId.Should().Be(3); context.Set <Sale>().ToList()[2].Date.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM")); }
public virtual ApiSaleClientRequestModel MapServerResponseToClientRequest( ApiSaleServerResponseModel response) { var request = new ApiSaleClientRequestModel(); request.SetProperties( response.CustomerId, response.Date); return(request); }
public virtual ApiSaleClientRequestModel MapServerResponseToClientRequest( ApiSaleServerResponseModel response) { var request = new ApiSaleClientRequestModel(); request.SetProperties( response.IpAddress, response.Notes, response.SaleDate, response.TransactionId); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiSaleModelMapper(); var model = new ApiSaleClientResponseModel(); model.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM")); ApiSaleClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.CustomerId.Should().Be(1); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public virtual ApiSaleClientRequestModel MapServerResponseToClientRequest( ApiSaleServerResponseModel response) { var request = new ApiSaleClientRequestModel(); request.SetProperties( response.Amount, response.CutomerId, response.Note, response.PetId, response.SaleDate, response.SalesPersonId); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiSaleModelMapper(); var model = new ApiSaleClientResponseModel(); model.SetProperties(1, "A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1); ApiSaleClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.IpAddress.Should().Be("A"); response.Notes.Should().Be("A"); response.SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.TransactionId.Should().Be(1); }
public virtual ApiSaleClientRequestModel MapServerResponseToClientRequest( ApiSaleServerResponseModel response) { var request = new ApiSaleClientRequestModel(); request.SetProperties( response.Amount, response.FirstName, response.LastName, response.PaymentTypeId, response.PetId, response.Phone); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiSaleModelMapper(); var model = new ApiSaleClientResponseModel(); model.SetProperties(1, 1m, 1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1); ApiSaleClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.Amount.Should().Be(1m); response.CutomerId.Should().Be(1); response.Note.Should().Be("A"); response.PetId.Should().Be(1); response.SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.SalesPersonId.Should().Be(1); }
public void MapClientResponseToRequest() { var mapper = new ApiSaleModelMapper(); var model = new ApiSaleClientResponseModel(); model.SetProperties(1, 1m, "A", "A", 1, 1, "A"); ApiSaleClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.Amount.Should().Be(1m); response.FirstName.Should().Be("A"); response.LastName.Should().Be("A"); response.PaymentTypeId.Should().Be(1); response.PetId.Should().Be(1); response.Phone.Should().Be("A"); }
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 ApiSaleClientRequestModel(); model.SetProperties(2m, "B", "B", 1, 1, "B"); var model2 = new ApiSaleClientRequestModel(); model2.SetProperties(3m, "C", "C", 1, 1, "C"); var request = new List <ApiSaleClientRequestModel>() { model, model2 }; CreateResponse <List <ApiSaleClientResponseModel> > result = await client.SaleBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Sale>().ToList()[1].Amount.Should().Be(2m); context.Set <Sale>().ToList()[1].FirstName.Should().Be("B"); context.Set <Sale>().ToList()[1].LastName.Should().Be("B"); context.Set <Sale>().ToList()[1].PaymentTypeId.Should().Be(1); context.Set <Sale>().ToList()[1].PetId.Should().Be(1); context.Set <Sale>().ToList()[1].Phone.Should().Be("B"); context.Set <Sale>().ToList()[2].Amount.Should().Be(3m); context.Set <Sale>().ToList()[2].FirstName.Should().Be("C"); context.Set <Sale>().ToList()[2].LastName.Should().Be("C"); context.Set <Sale>().ToList()[2].PaymentTypeId.Should().Be(1); context.Set <Sale>().ToList()[2].PetId.Should().Be(1); context.Set <Sale>().ToList()[2].Phone.Should().Be("C"); }