public virtual async void TestBulkInsert() { 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 ApiFollowingClientRequestModel(); model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), "B"); var model2 = new ApiFollowingClientRequestModel(); model2.SetProperties(DateTime.Parse("1/1/1989 12:00:00 AM"), "C"); var request = new List <ApiFollowingClientRequestModel>() { model, model2 }; CreateResponse <List <ApiFollowingClientResponseModel> > result = await client.FollowingBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Following>().ToList()[1].DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Following>().ToList()[1].Muted.Should().Be("B"); context.Set <Following>().ToList()[2].DateFollowed.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM")); context.Set <Following>().ToList()[2].Muted.Should().Be("C"); }
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 ApiFollowingServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IFollowingService service = testServer.Host.Services.GetService(typeof(IFollowingService)) as IFollowingService; ApiFollowingServerResponseModel model = await service.Get(1); ApiFollowingClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), "B"); UpdateResponse <ApiFollowingClientResponseModel> updateResponse = await client.FollowingUpdateAsync(model.UserId, request); context.Entry(context.Set <Following>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.UserId.Should().Be(1); context.Set <Following>().ToList()[0].DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Following>().ToList()[0].Muted.Should().Be("B"); updateResponse.Record.UserId.Should().Be(1); updateResponse.Record.DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.Muted.Should().Be("B"); }
public virtual ApiFollowingClientRequestModel MapServerResponseToClientRequest( ApiFollowingServerResponseModel response) { var request = new ApiFollowingClientRequestModel(); request.SetProperties( response.DateFollowed, response.Muted); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiFollowingModelMapper(); var model = new ApiFollowingClientResponseModel(); model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A"); ApiFollowingClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.Muted.Should().Be("A"); }