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;

            IPostHistoryService service = testServer.Host.Services.GetService(typeof(IPostHistoryService)) as IPostHistoryService;
            var model = new ApiPostHistoryServerRequestModel();

            model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B", "B", 1);
            CreateResponse <ApiPostHistoryServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.PostHistoryDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
 public AbstractPostHistoryController(
     ApiSettings settings,
     ILogger <AbstractPostHistoryController> logger,
     ITransactionCoordinator transactionCoordinator,
     IPostHistoryService postHistoryService,
     IApiPostHistoryModelMapper postHistoryModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.PostHistoryService     = postHistoryService;
     this.PostHistoryModelMapper = postHistoryModelMapper;
 }
Ejemplo n.º 3
0
 public PostHistoryController(
     ApiSettings settings,
     ILogger <PostHistoryController> logger,
     ITransactionCoordinator transactionCoordinator,
     IPostHistoryService postHistoryService,
     IApiPostHistoryServerModelMapper postHistoryModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.PostHistoryService     = postHistoryService;
     this.PostHistoryModelMapper = postHistoryModelMapper;
     this.BulkInsertLimit        = 250;
     this.MaxLimit     = 1000;
     this.DefaultLimit = 250;
 }
        public virtual async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiPostHistoryServerModelMapper();
            ApplicationDbContext context            = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IPostHistoryService  service            = testServer.Host.Services.GetService(typeof(IPostHistoryService)) as IPostHistoryService;
            ApiPostHistoryServerResponseModel model = await service.Get(1);

            ApiPostHistoryClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B", "B", 1);

            UpdateResponse <ApiPostHistoryClientResponseModel> updateResponse = await client.PostHistoryUpdateAsync(model.Id, request);

            context.Entry(context.Set <PostHistory>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <PostHistory>().ToList()[0].Comment.Should().Be("B");
            context.Set <PostHistory>().ToList()[0].CreationDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <PostHistory>().ToList()[0].PostHistoryTypeId.Should().Be(1);
            context.Set <PostHistory>().ToList()[0].PostId.Should().Be(1);
            context.Set <PostHistory>().ToList()[0].RevisionGUID.Should().Be("B");
            context.Set <PostHistory>().ToList()[0].Text.Should().Be("B");
            context.Set <PostHistory>().ToList()[0].UserDisplayName.Should().Be("B");
            context.Set <PostHistory>().ToList()[0].UserId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Comment.Should().Be("B");
            updateResponse.Record.CreationDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.PostHistoryTypeId.Should().Be(1);
            updateResponse.Record.PostId.Should().Be(1);
            updateResponse.Record.RevisionGUID.Should().Be("B");
            updateResponse.Record.Text.Should().Be("B");
            updateResponse.Record.UserDisplayName.Should().Be("B");
            updateResponse.Record.UserId.Should().Be(1);
        }