public virtual async void TestCreate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; var model = new ApiFamilyClientRequestModel(); model.SetProperties("B", "B", "B", "B", "B"); CreateResponse <ApiFamilyClientResponseModel> result = await client.FamilyCreateAsync(model); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Family>().ToList()[1].Notes.Should().Be("B"); context.Set <Family>().ToList()[1].PrimaryContactEmail.Should().Be("B"); context.Set <Family>().ToList()[1].PrimaryContactFirstName.Should().Be("B"); context.Set <Family>().ToList()[1].PrimaryContactLastName.Should().Be("B"); context.Set <Family>().ToList()[1].PrimaryContactPhone.Should().Be("B"); result.Record.Notes.Should().Be("B"); result.Record.PrimaryContactEmail.Should().Be("B"); result.Record.PrimaryContactFirstName.Should().Be("B"); result.Record.PrimaryContactLastName.Should().Be("B"); result.Record.PrimaryContactPhone.Should().Be("B"); }
public virtual ApiFamilyClientRequestModel MapServerResponseToClientRequest( ApiFamilyServerResponseModel response) { var request = new ApiFamilyClientRequestModel(); request.SetProperties( response.Notes, response.PrimaryContactEmail, response.PrimaryContactFirstName, response.PrimaryContactLastName, response.PrimaryContactPhone); return(request); }
public void MapClientRequestToResponse() { var mapper = new ApiFamilyModelMapper(); var model = new ApiFamilyClientRequestModel(); model.SetProperties("A", "A", "A", "A", "A"); ApiFamilyClientResponseModel response = mapper.MapClientRequestToResponse(1, 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 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"); }