public void MapServerResponseToRequest() { var mapper = new ApiFollowerServerModelMapper(); var model = new ApiFollowerServerResponseModel(); model.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", "A"); ApiFollowerServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.Blocked.Should().Be("A"); response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.FollowedUserId.Should().Be(1); response.FollowingUserId.Should().Be(1); response.FollowRequestStatu.Should().Be("A"); response.Muted.Should().Be("A"); }
public void CreatePatch() { var mapper = new ApiFollowerServerModelMapper(); var model = new ApiFollowerServerRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", "A"); JsonPatchDocument <ApiFollowerServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiFollowerServerRequestModel(); patch.ApplyTo(response); response.Blocked.Should().Be("A"); response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.FollowedUserId.Should().Be(1); response.FollowingUserId.Should().Be(1); response.FollowRequestStatu.Should().Be("A"); response.Muted.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 ApiFollowerServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IFollowerService service = testServer.Host.Services.GetService(typeof(IFollowerService)) as IFollowerService; ApiFollowerServerResponseModel model = await service.Get(1); ApiFollowerClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B"); UpdateResponse <ApiFollowerClientResponseModel> updateResponse = await client.FollowerUpdateAsync(model.Id, request); context.Entry(context.Set <Follower>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Follower>().ToList()[0].Blocked.Should().Be("B"); context.Set <Follower>().ToList()[0].DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Follower>().ToList()[0].FollowedUserId.Should().Be(1); context.Set <Follower>().ToList()[0].FollowingUserId.Should().Be(1); context.Set <Follower>().ToList()[0].FollowRequestStatu.Should().Be("B"); context.Set <Follower>().ToList()[0].Muted.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Blocked.Should().Be("B"); updateResponse.Record.DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.FollowedUserId.Should().Be(1); updateResponse.Record.FollowingUserId.Should().Be(1); updateResponse.Record.FollowRequestStatu.Should().Be("B"); updateResponse.Record.Muted.Should().Be("B"); }