public void MapServerResponseToRequest() { var mapper = new ApiOfficerServerModelMapper(); var model = new ApiOfficerServerResponseModel(); model.SetProperties(1, "A", "A", "A", "A", "A"); ApiOfficerServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.Badge.Should().Be("A"); response.Email.Should().Be("A"); response.FirstName.Should().Be("A"); response.LastName.Should().Be("A"); response.Password.Should().Be("A"); }
public void CreatePatch() { var mapper = new ApiOfficerServerModelMapper(); var model = new ApiOfficerServerRequestModel(); model.SetProperties("A", "A", "A", "A", "A"); JsonPatchDocument <ApiOfficerServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiOfficerServerRequestModel(); patch.ApplyTo(response); response.Badge.Should().Be("A"); response.Email.Should().Be("A"); response.FirstName.Should().Be("A"); response.LastName.Should().Be("A"); response.Password.Should().Be("A"); }
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 ApiOfficerServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IOfficerService service = testServer.Host.Services.GetService(typeof(IOfficerService)) as IOfficerService; ApiOfficerServerResponseModel model = await service.Get(1); ApiOfficerClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", "B", "B", "B", "B"); UpdateResponse <ApiOfficerClientResponseModel> updateResponse = await client.OfficerUpdateAsync(model.Id, request); context.Entry(context.Set <Officer>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Officer>().ToList()[0].Badge.Should().Be("B"); context.Set <Officer>().ToList()[0].Email.Should().Be("B"); context.Set <Officer>().ToList()[0].FirstName.Should().Be("B"); context.Set <Officer>().ToList()[0].LastName.Should().Be("B"); context.Set <Officer>().ToList()[0].Password.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Badge.Should().Be("B"); updateResponse.Record.Email.Should().Be("B"); updateResponse.Record.FirstName.Should().Be("B"); updateResponse.Record.LastName.Should().Be("B"); updateResponse.Record.Password.Should().Be("B"); }