public async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            var createModel = new ApiTweetRequestModel();

            createModel.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("1"), 1);
            CreateResponse <ApiTweetResponseModel> createResult = await client.TweetCreateAsync(createModel);

            createResult.Success.Should().BeTrue();

            ApiTweetResponseModel getResponse = await client.TweetGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.TweetDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();

            ApiTweetResponseModel verifyResponse = await client.TweetGetAsync(2);

            verifyResponse.Should().BeNull();
        }
        private async Task <ApiTweetResponseModel> CreateRecord(ApiClient client)
        {
            var model = new ApiTweetRequestModel();

            model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("1"), 1);
            CreateResponse <ApiTweetResponseModel> result = await client.TweetCreateAsync(model);

            result.Success.Should().BeTrue();
            return(result.Record);
        }
示例#3
0
        public void MapModelToBO()
        {
            var mapper = new BOLTweetMapper();
            ApiTweetRequestModel model = new ApiTweetRequestModel();

            model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"), 1);
            BOTweet response = mapper.MapModelToBO(1, 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);
        }