コード例 #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;

            ICallAssignmentService service = testServer.Host.Services.GetService(typeof(ICallAssignmentService)) as ICallAssignmentService;
            var model = new ApiCallAssignmentServerRequestModel();

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

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

            ActionResponse deleteResult = await client.CallAssignmentDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
コード例 #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 ApiCallAssignmentServerModelMapper();
            ApplicationDbContext   context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ICallAssignmentService service             = testServer.Host.Services.GetService(typeof(ICallAssignmentService)) as ICallAssignmentService;
            ApiCallAssignmentServerResponseModel model = await service.Get(1);

            ApiCallAssignmentClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiCallAssignmentClientResponseModel> updateResponse = await client.CallAssignmentUpdateAsync(model.Id, request);

            context.Entry(context.Set <CallAssignment>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <CallAssignment>().ToList()[0].CallId.Should().Be(1);
            context.Set <CallAssignment>().ToList()[0].UnitId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CallId.Should().Be(1);
            updateResponse.Record.UnitId.Should().Be(1);
        }
コード例 #3
0
 public CallAssignmentController(
     ApiSettings settings,
     ILogger <CallAssignmentController> logger,
     ITransactionCoordinator transactionCoordinator,
     ICallAssignmentService callAssignmentService,
     IApiCallAssignmentServerModelMapper callAssignmentModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.CallAssignmentService     = callAssignmentService;
     this.CallAssignmentModelMapper = callAssignmentModelMapper;
     this.BulkInsertLimit           = 250;
     this.MaxLimit     = 1000;
     this.DefaultLimit = 250;
 }