public void MapResponseToRequest()
        {
            var mapper = new ApiPostLinkModelMapper();
            var model  = new ApiPostLinkResponseModel();

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

            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LinkTypeId.Should().Be(1);
            response.PostId.Should().Be(1);
            response.RelatedPostId.Should().Be(1);
        }
        public void CreatePatch()
        {
            var mapper = new ApiPostLinkModelMapper();
            var model  = new ApiPostLinkRequestModel();

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

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

            patch.ApplyTo(response);
            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LinkTypeId.Should().Be(1);
            response.PostId.Should().Be(1);
            response.RelatedPostId.Should().Be(1);
        }
Esempio 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());

            ApiPostLinkResponseModel model = await client.PostLinkGetAsync(1);

            ApiPostLinkModelMapper mapper = new ApiPostLinkModelMapper();

            UpdateResponse <ApiPostLinkResponseModel> updateResponse = await client.PostLinkUpdateAsync(model.Id, mapper.MapResponseToRequest(model));

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