public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); var mapper = new ApiArtistServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IArtistService service = testServer.Host.Services.GetService(typeof(IArtistService)) as IArtistService; ApiArtistServerResponseModel model = await service.Get(1); ApiArtistClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", "B", "B", "B", "B", "B"); UpdateResponse <ApiArtistClientResponseModel> updateResponse = await client.ArtistUpdateAsync(model.Id, request); context.Entry(context.Set <Artist>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Artist>().ToList()[0].AspNetUserId.Should().Be("B"); context.Set <Artist>().ToList()[0].Bio.Should().Be("B"); context.Set <Artist>().ToList()[0].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); context.Set <Artist>().ToList()[0].Facebook.Should().Be("B"); context.Set <Artist>().ToList()[0].Name.Should().Be("B"); context.Set <Artist>().ToList()[0].SoundCloud.Should().Be("B"); context.Set <Artist>().ToList()[0].Twitter.Should().Be("B"); context.Set <Artist>().ToList()[0].Venmo.Should().Be("B"); context.Set <Artist>().ToList()[0].Website.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.AspNetUserId.Should().Be("B"); updateResponse.Record.Bio.Should().Be("B"); updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); updateResponse.Record.Facebook.Should().Be("B"); updateResponse.Record.Name.Should().Be("B"); updateResponse.Record.SoundCloud.Should().Be("B"); updateResponse.Record.Twitter.Should().Be("B"); updateResponse.Record.Venmo.Should().Be("B"); updateResponse.Record.Website.Should().Be("B"); }
public void MapServerResponseToRequest() { var mapper = new ApiArtistServerModelMapper(); var model = new ApiArtistServerResponseModel(); model.SetProperties(1, "A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A", "A", "A", "A", "A"); ApiArtistServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.AspNetUserId.Should().Be("A"); response.Bio.Should().Be("A"); response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.Facebook.Should().Be("A"); response.Name.Should().Be("A"); response.SoundCloud.Should().Be("A"); response.Twitter.Should().Be("A"); response.Venmo.Should().Be("A"); response.Website.Should().Be("A"); }
public void CreatePatch() { var mapper = new ApiArtistServerModelMapper(); var model = new ApiArtistServerRequestModel(); model.SetProperties("A", "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", "A", "A", "A", "A", "A"); JsonPatchDocument <ApiArtistServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiArtistServerRequestModel(); patch.ApplyTo(response); response.AspNetUserId.Should().Be("A"); response.Bio.Should().Be("A"); response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.Facebook.Should().Be("A"); response.Name.Should().Be("A"); response.SoundCloud.Should().Be("A"); response.Twitter.Should().Be("A"); response.Venmo.Should().Be("A"); response.Website.Should().Be("A"); }