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 ApiEventStudentServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IEventStudentService service = testServer.Host.Services.GetService(typeof(IEventStudentService)) as IEventStudentService; ApiEventStudentServerResponseModel model = await service.Get(1); ApiEventStudentClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, 1); UpdateResponse <ApiEventStudentClientResponseModel> updateResponse = await client.EventStudentUpdateAsync(model.Id, request); context.Entry(context.Set <EventStudent>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <EventStudent>().ToList()[0].EventId.Should().Be(1); context.Set <EventStudent>().ToList()[0].StudentId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.EventId.Should().Be(1); updateResponse.Record.StudentId.Should().Be(1); }
public void MapServerResponseToRequest() { var mapper = new ApiEventStudentServerModelMapper(); var model = new ApiEventStudentServerResponseModel(); model.SetProperties(1, 1, 1); ApiEventStudentServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.EventId.Should().Be(1); response.StudentId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiEventStudentServerModelMapper(); var model = new ApiEventStudentServerRequestModel(); model.SetProperties(1, 1); JsonPatchDocument <ApiEventStudentServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiEventStudentServerRequestModel(); patch.ApplyTo(response); response.EventId.Should().Be(1); response.StudentId.Should().Be(1); }