public void MapResponseToRequest()
        {
            var mapper = new ApiDirectTweetModelMapper();
            var model  = new ApiDirectTweetResponseModel();

            model.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"));
            ApiDirectTweetRequestModel response = mapper.MapResponseToRequest(model);

            response.Content.Should().Be("A");
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.TaggedUserId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("0"));
        }
        public void CreatePatch()
        {
            var mapper = new ApiDirectTweetModelMapper();
            var model  = new ApiDirectTweetRequestModel();

            model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"));

            JsonPatchDocument <ApiDirectTweetRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiDirectTweetRequestModel();

            patch.ApplyTo(response);
            response.Content.Should().Be("A");
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.TaggedUserId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("0"));
        }
Exemplo n.º 3
0
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            ApiDirectTweetResponseModel model = await client.DirectTweetGetAsync(1);

            ApiDirectTweetModelMapper mapper = new ApiDirectTweetModelMapper();

            UpdateResponse <ApiDirectTweetResponseModel> updateResponse = await client.DirectTweetUpdateAsync(model.TweetId, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }