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 ApiPipelineStepServerModelMapper();
            ApplicationDbContext context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IPipelineStepService service             = testServer.Host.Services.GetService(typeof(IPipelineStepService)) as IPipelineStepService;
            ApiPipelineStepServerResponseModel model = await service.Get(1);

            ApiPipelineStepClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", 1, 1);

            UpdateResponse <ApiPipelineStepClientResponseModel> updateResponse = await client.PipelineStepUpdateAsync(model.Id, request);

            context.Entry(context.Set <PipelineStep>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <PipelineStep>().ToList()[0].Name.Should().Be("B");
            context.Set <PipelineStep>().ToList()[0].PipelineStepStatusId.Should().Be(1);
            context.Set <PipelineStep>().ToList()[0].ShipperId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.PipelineStepStatusId.Should().Be(1);
            updateResponse.Record.ShipperId.Should().Be(1);
        }
        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;

            IPipelineStepService service = testServer.Host.Services.GetService(typeof(IPipelineStepService)) as IPipelineStepService;
            var model = new ApiPipelineStepServerRequestModel();

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

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

            ActionResponse deleteResult = await client.PipelineStepDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Пример #3
0
 public AbstractPipelineStepController(
     ApiSettings settings,
     ILogger <AbstractPipelineStepController> logger,
     ITransactionCoordinator transactionCoordinator,
     IPipelineStepService pipelineStepService,
     IApiPipelineStepModelMapper pipelineStepModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.PipelineStepService     = pipelineStepService;
     this.PipelineStepModelMapper = pipelineStepModelMapper;
 }
Пример #4
0
 public PipelineStepController(
     ApiSettings settings,
     ILogger <PipelineStepController> logger,
     ITransactionCoordinator transactionCoordinator,
     IPipelineStepService pipelineStepService,
     IApiPipelineStepServerModelMapper pipelineStepModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.PipelineStepService     = pipelineStepService;
     this.PipelineStepModelMapper = pipelineStepModelMapper;
     this.BulkInsertLimit         = 250;
     this.MaxLimit     = 1000;
     this.DefaultLimit = 250;
 }