public virtual async void TestBulkInsert()
        {
            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;

            var model = new ApiOfficerCapabilitiesClientRequestModel();

            model.SetProperties(1, 1);
            var model2 = new ApiOfficerCapabilitiesClientRequestModel();

            model2.SetProperties(1, 1);
            var request = new List <ApiOfficerCapabilitiesClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiOfficerCapabilitiesClientResponseModel> > result = await client.OfficerCapabilitiesBulkInsertAsync(request);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();

            context.Set <OfficerCapabilities>().ToList()[1].CapabilityId.Should().Be(1);
            context.Set <OfficerCapabilities>().ToList()[1].OfficerId.Should().Be(1);

            context.Set <OfficerCapabilities>().ToList()[2].CapabilityId.Should().Be(1);
            context.Set <OfficerCapabilities>().ToList()[2].OfficerId.Should().Be(1);
        }
        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 ApiOfficerCapabilitiesServerModelMapper();
            ApplicationDbContext        context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IOfficerCapabilitiesService service             = testServer.Host.Services.GetService(typeof(IOfficerCapabilitiesService)) as IOfficerCapabilitiesService;
            ApiOfficerCapabilitiesServerResponseModel model = await service.Get(1);

            ApiOfficerCapabilitiesClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiOfficerCapabilitiesClientResponseModel> updateResponse = await client.OfficerCapabilitiesUpdateAsync(model.Id, request);

            context.Entry(context.Set <OfficerCapabilities>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <OfficerCapabilities>().ToList()[0].CapabilityId.Should().Be(1);
            context.Set <OfficerCapabilities>().ToList()[0].OfficerId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CapabilityId.Should().Be(1);
            updateResponse.Record.OfficerId.Should().Be(1);
        }
Beispiel #3
0
        public virtual ApiOfficerCapabilitiesClientRequestModel MapServerResponseToClientRequest(
            ApiOfficerCapabilitiesServerResponseModel response)
        {
            var request = new ApiOfficerCapabilitiesClientRequestModel();

            request.SetProperties(
                response.CapabilityId,
                response.OfficerId);
            return(request);
        }
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiOfficerCapabilitiesModelMapper();
            var model  = new ApiOfficerCapabilitiesClientResponseModel();

            model.SetProperties(1, 1, 1);
            ApiOfficerCapabilitiesClientRequestModel response = mapper.MapClientResponseToRequest(model);

            response.Should().NotBeNull();
            response.CapabilityId.Should().Be(1);
            response.OfficerId.Should().Be(1);
        }