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 ApiLocationServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ILocationService service = testServer.Host.Services.GetService(typeof(ILocationService)) as ILocationService; ApiLocationServerResponseModel model = await service.Get(1); ApiLocationClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(2, 2, "B"); UpdateResponse <ApiLocationClientResponseModel> updateResponse = await client.LocationUpdateAsync(model.LocationId, request); context.Entry(context.Set <Location>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.LocationId.Should().Be(1); context.Set <Location>().ToList()[0].GpsLat.Should().Be(2); context.Set <Location>().ToList()[0].GpsLong.Should().Be(2); context.Set <Location>().ToList()[0].LocationName.Should().Be("B"); updateResponse.Record.LocationId.Should().Be(1); updateResponse.Record.GpsLat.Should().Be(2); updateResponse.Record.GpsLong.Should().Be(2); updateResponse.Record.LocationName.Should().Be("B"); }
public void MapServerResponseToRequest() { var mapper = new ApiLocationServerModelMapper(); var model = new ApiLocationServerResponseModel(); model.SetProperties(1, 1, 1, "A"); ApiLocationServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.GpsLat.Should().Be(1); response.GpsLong.Should().Be(1); response.LocationName.Should().Be("A"); }
public void CreatePatch() { var mapper = new ApiLocationServerModelMapper(); var model = new ApiLocationServerRequestModel(); model.SetProperties(1, 1, "A"); JsonPatchDocument <ApiLocationServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiLocationServerRequestModel(); patch.ApplyTo(response); response.GpsLat.Should().Be(1); response.GpsLong.Should().Be(1); response.LocationName.Should().Be("A"); }