public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); var mapper = new ApiBankAccountServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IBankAccountService service = testServer.Host.Services.GetService(typeof(IBankAccountService)) as IBankAccountService; ApiBankAccountServerResponseModel model = await service.Get(1); ApiBankAccountClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", 1, "B"); UpdateResponse <ApiBankAccountClientResponseModel> updateResponse = await client.BankAccountUpdateAsync(model.Id, request); context.Entry(context.Set <BankAccount>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <BankAccount>().ToList()[0].AccountNumber.Should().Be("B"); context.Set <BankAccount>().ToList()[0].ArtistId.Should().Be(1); context.Set <BankAccount>().ToList()[0].RoutingNumber.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.AccountNumber.Should().Be("B"); updateResponse.Record.ArtistId.Should().Be(1); updateResponse.Record.RoutingNumber.Should().Be("B"); }
public void MapServerResponseToRequest() { var mapper = new ApiBankAccountServerModelMapper(); var model = new ApiBankAccountServerResponseModel(); model.SetProperties(1, "A", 1, "A"); ApiBankAccountServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.AccountNumber.Should().Be("A"); response.ArtistId.Should().Be(1); response.RoutingNumber.Should().Be("A"); }
public void CreatePatch() { var mapper = new ApiBankAccountServerModelMapper(); var model = new ApiBankAccountServerRequestModel(); model.SetProperties("A", 1, "A"); JsonPatchDocument <ApiBankAccountServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiBankAccountServerRequestModel(); patch.ApplyTo(response); response.AccountNumber.Should().Be("A"); response.ArtistId.Should().Be(1); response.RoutingNumber.Should().Be("A"); }