public void MapResponseToRequest() { var mapper = new ApiTweetModelMapper(); var model = new ApiTweetResponseModel(); model.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"), 1); ApiTweetRequestModel response = mapper.MapResponseToRequest(model); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.LocationId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("0")); response.UserUserId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiTweetModelMapper(); var model = new ApiTweetRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"), 1); JsonPatchDocument <ApiTweetRequestModel> patch = mapper.CreatePatch(model); var response = new ApiTweetRequestModel(); patch.ApplyTo(response); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.LocationId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("0")); response.UserUserId.Should().Be(1); }
public async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); ApiTweetResponseModel model = await client.TweetGetAsync(1); ApiTweetModelMapper mapper = new ApiTweetModelMapper(); UpdateResponse <ApiTweetResponseModel> updateResponse = await client.TweetUpdateAsync(model.TweetId, mapper.MapResponseToRequest(model)); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); }