示例#1
0
        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 ApiMessageRequestModel();

            createModel.SetProperties("B", 1);
            CreateResponse <ApiMessageResponseModel> createResult = await client.MessageCreateAsync(createModel);

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

            ApiMessageResponseModel getResponse = await client.MessageGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.MessageDeleteAsync(2);

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

            ApiMessageResponseModel verifyResponse = await client.MessageGetAsync(2);

            verifyResponse.Should().BeNull();
        }
示例#2
0
        private async Task <ApiMessageResponseModel> CreateRecord(ApiClient client)
        {
            var model = new ApiMessageRequestModel();

            model.SetProperties("B", 1);
            CreateResponse <ApiMessageResponseModel> result = await client.MessageCreateAsync(model);

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

            model.SetProperties("A", 1);
            BOMessage response = mapper.MapModelToBO(1, model);

            response.Content.Should().Be("A");
            response.SenderUserId.Should().Be(1);
        }
示例#4
0
        public void MapRequestToResponse()
        {
            var mapper = new ApiMessageModelMapper();
            var model  = new ApiMessageRequestModel();

            model.SetProperties("A", 1);
            ApiMessageResponseModel response = mapper.MapRequestToResponse(1, model);

            response.Content.Should().Be("A");
            response.MessageId.Should().Be(1);
            response.SenderUserId.Should().Be(1);
        }
示例#5
0
        public void CreatePatch()
        {
            var mapper = new ApiMessageModelMapper();
            var model  = new ApiMessageRequestModel();

            model.SetProperties("A", 1);

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

            patch.ApplyTo(response);
            response.Content.Should().Be("A");
            response.SenderUserId.Should().Be(1);
        }