Exemplo n.º 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;

            IColumnSameAsFKTableService service = testServer.Host.Services.GetService(typeof(IColumnSameAsFKTableService)) as IColumnSameAsFKTableService;
            var model = new ApiColumnSameAsFKTableServerRequestModel();

            model.SetProperties(1, 1);
            CreateResponse <ApiColumnSameAsFKTableServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.ColumnSameAsFKTableDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Exemplo n.º 2
0
        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 ApiColumnSameAsFKTableServerModelMapper();
            ApplicationDbContext        context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IColumnSameAsFKTableService service             = testServer.Host.Services.GetService(typeof(IColumnSameAsFKTableService)) as IColumnSameAsFKTableService;
            ApiColumnSameAsFKTableServerResponseModel model = await service.Get(1);

            ApiColumnSameAsFKTableClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiColumnSameAsFKTableClientResponseModel> updateResponse = await client.ColumnSameAsFKTableUpdateAsync(model.Id, request);

            context.Entry(context.Set <ColumnSameAsFKTable>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <ColumnSameAsFKTable>().ToList()[0].Person.Should().Be(1);
            context.Set <ColumnSameAsFKTable>().ToList()[0].PersonId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Person.Should().Be(1);
            updateResponse.Record.PersonId.Should().Be(1);
        }
 public AbstractColumnSameAsFKTableController(
     ApiSettings settings,
     ILogger <AbstractColumnSameAsFKTableController> logger,
     ITransactionCoordinator transactionCoordinator,
     IColumnSameAsFKTableService columnSameAsFKTableService,
     IApiColumnSameAsFKTableModelMapper columnSameAsFKTableModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.ColumnSameAsFKTableService     = columnSameAsFKTableService;
     this.ColumnSameAsFKTableModelMapper = columnSameAsFKTableModelMapper;
 }
Exemplo n.º 4
0
 public ColumnSameAsFKTableController(
     ApiSettings settings,
     ILogger <ColumnSameAsFKTableController> logger,
     ITransactionCoordinator transactionCoordinator,
     IColumnSameAsFKTableService columnSameAsFKTableService,
     IApiColumnSameAsFKTableServerModelMapper columnSameAsFKTableModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.ColumnSameAsFKTableService     = columnSameAsFKTableService;
     this.ColumnSameAsFKTableModelMapper = columnSameAsFKTableModelMapper;
     this.BulkInsertLimit = 250;
     this.MaxLimit        = 1000;
     this.DefaultLimit    = 250;
 }