예제 #1
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            ITagService service = testServer.Host.Services.GetService(typeof(ITagService)) as ITagService;
            var         model   = new ApiTagServerRequestModel();

            model.SetProperties(2, 1, "B", 1);
            CreateResponse <ApiTagServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.TagDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiTagServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiTagServerModelMapper();
            var model  = new ApiTagServerRequestModel();

            model.SetProperties(1, 1, "A", 1);
            ApiTagServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Count.Should().Be(1);
            response.ExcerptPostId.Should().Be(1);
            response.TagName.Should().Be("A");
            response.WikiPostId.Should().Be(1);
        }
        public void CreatePatch()
        {
            var mapper = new ApiTagServerModelMapper();
            var model  = new ApiTagServerRequestModel();

            model.SetProperties(1, 1, "A", 1);

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

            patch.ApplyTo(response);
            response.Count.Should().Be(1);
            response.ExcerptPostId.Should().Be(1);
            response.TagName.Should().Be("A");
            response.WikiPostId.Should().Be(1);
        }