public void MapServerResponseToRequest() { var mapper = new ApiFamilyServerModelMapper(); var model = new ApiFamilyServerResponseModel(); model.SetProperties(1, "A", "A", "A", "A", "A"); ApiFamilyServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.Notes.Should().Be("A"); response.PrimaryContactEmail.Should().Be("A"); response.PrimaryContactFirstName.Should().Be("A"); response.PrimaryContactLastName.Should().Be("A"); response.PrimaryContactPhone.Should().Be("A"); }
public void CreatePatch() { var mapper = new ApiFamilyServerModelMapper(); var model = new ApiFamilyServerRequestModel(); model.SetProperties("A", "A", "A", "A", "A"); JsonPatchDocument <ApiFamilyServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiFamilyServerRequestModel(); patch.ApplyTo(response); response.Notes.Should().Be("A"); response.PrimaryContactEmail.Should().Be("A"); response.PrimaryContactFirstName.Should().Be("A"); response.PrimaryContactLastName.Should().Be("A"); response.PrimaryContactPhone.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 ApiFamilyServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IFamilyService service = testServer.Host.Services.GetService(typeof(IFamilyService)) as IFamilyService; ApiFamilyServerResponseModel model = await service.Get(1); ApiFamilyClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", "B", "B", "B", "B"); UpdateResponse <ApiFamilyClientResponseModel> updateResponse = await client.FamilyUpdateAsync(model.Id, request); context.Entry(context.Set <Family>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Family>().ToList()[0].Notes.Should().Be("B"); context.Set <Family>().ToList()[0].PrimaryContactEmail.Should().Be("B"); context.Set <Family>().ToList()[0].PrimaryContactFirstName.Should().Be("B"); context.Set <Family>().ToList()[0].PrimaryContactLastName.Should().Be("B"); context.Set <Family>().ToList()[0].PrimaryContactPhone.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Notes.Should().Be("B"); updateResponse.Record.PrimaryContactEmail.Should().Be("B"); updateResponse.Record.PrimaryContactFirstName.Should().Be("B"); updateResponse.Record.PrimaryContactLastName.Should().Be("B"); updateResponse.Record.PrimaryContactPhone.Should().Be("B"); }