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

            ITimestampCheckService service = testServer.Host.Services.GetService(typeof(ITimestampCheckService)) as ITimestampCheckService;
            var model = new ApiTimestampCheckServerRequestModel();

            model.SetProperties("B", BitConverter.GetBytes(2));
            CreateResponse <ApiTimestampCheckServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.TimestampCheckDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Example #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 ApiTimestampCheckServerModelMapper();
            ApplicationDbContext   context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ITimestampCheckService service             = testServer.Host.Services.GetService(typeof(ITimestampCheckService)) as ITimestampCheckService;
            ApiTimestampCheckServerResponseModel model = await service.Get(1);

            ApiTimestampCheckClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", BitConverter.GetBytes(2));

            UpdateResponse <ApiTimestampCheckClientResponseModel> updateResponse = await client.TimestampCheckUpdateAsync(model.Id, request);

            context.Entry(context.Set <TimestampCheck>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <TimestampCheck>().ToList()[0].Name.Should().Be("B");
            context.Set <TimestampCheck>().ToList()[0].Timestamp.Should().BeEquivalentTo(BitConverter.GetBytes(2));

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.Timestamp.Should().BeEquivalentTo(BitConverter.GetBytes(2));
        }
Example #3
0
 public AbstractTimestampCheckController(
     ApiSettings settings,
     ILogger <AbstractTimestampCheckController> logger,
     ITransactionCoordinator transactionCoordinator,
     ITimestampCheckService timestampCheckService,
     IApiTimestampCheckModelMapper timestampCheckModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.TimestampCheckService     = timestampCheckService;
     this.TimestampCheckModelMapper = timestampCheckModelMapper;
 }
Example #4
0
 public TimestampCheckController(
     ApiSettings settings,
     ILogger <TimestampCheckController> logger,
     ITransactionCoordinator transactionCoordinator,
     ITimestampCheckService timestampCheckService,
     IApiTimestampCheckServerModelMapper timestampCheckModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.TimestampCheckService     = timestampCheckService;
     this.TimestampCheckModelMapper = timestampCheckModelMapper;
     this.BulkInsertLimit           = 250;
     this.MaxLimit     = 1000;
     this.DefaultLimit = 250;
 }