Beispiel #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;

            ICountryRequirementService service = testServer.Host.Services.GetService(typeof(ICountryRequirementService)) as ICountryRequirementService;
            var model = new ApiCountryRequirementServerRequestModel();

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

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

            ActionResponse deleteResult = await client.CountryRequirementDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Beispiel #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 ApiCountryRequirementServerModelMapper();
            ApplicationDbContext       context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ICountryRequirementService service             = testServer.Host.Services.GetService(typeof(ICountryRequirementService)) as ICountryRequirementService;
            ApiCountryRequirementServerResponseModel model = await service.Get(1);

            ApiCountryRequirementClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, "B");

            UpdateResponse <ApiCountryRequirementClientResponseModel> updateResponse = await client.CountryRequirementUpdateAsync(model.Id, request);

            context.Entry(context.Set <CountryRequirement>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <CountryRequirement>().ToList()[0].CountryId.Should().Be(1);
            context.Set <CountryRequirement>().ToList()[0].Details.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CountryId.Should().Be(1);
            updateResponse.Record.Details.Should().Be("B");
        }
 public AbstractCountryRequirementController(
     ApiSettings settings,
     ILogger <AbstractCountryRequirementController> logger,
     ITransactionCoordinator transactionCoordinator,
     ICountryRequirementService countryRequirementService,
     IApiCountryRequirementModelMapper countryRequirementModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.CountryRequirementService     = countryRequirementService;
     this.CountryRequirementModelMapper = countryRequirementModelMapper;
 }
 public CountryRequirementController(
     ApiSettings settings,
     ILogger <CountryRequirementController> logger,
     ITransactionCoordinator transactionCoordinator,
     ICountryRequirementService countryRequirementService,
     IApiCountryRequirementServerModelMapper countryRequirementModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.CountryRequirementService     = countryRequirementService;
     this.CountryRequirementModelMapper = countryRequirementModelMapper;
     this.BulkInsertLimit = 250;
     this.MaxLimit        = 1000;
     this.DefaultLimit    = 250;
 }