Exemple #1
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 ApiVehicleCapabilitiesServerModelMapper();
            ApplicationDbContext        context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IVehicleCapabilitiesService service             = testServer.Host.Services.GetService(typeof(IVehicleCapabilitiesService)) as IVehicleCapabilitiesService;
            ApiVehicleCapabilitiesServerResponseModel model = await service.Get(1);

            ApiVehicleCapabilitiesClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiVehicleCapabilitiesClientResponseModel> updateResponse = await client.VehicleCapabilitiesUpdateAsync(model.Id, request);

            context.Entry(context.Set <VehicleCapabilities>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <VehicleCapabilities>().ToList()[0].VehicleCapabilityId.Should().Be(1);
            context.Set <VehicleCapabilities>().ToList()[0].VehicleId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.VehicleCapabilityId.Should().Be(1);
            updateResponse.Record.VehicleId.Should().Be(1);
        }
Exemple #2
0
        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 ApiVehicleCapabilitiesClientRequestModel();

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

            model2.SetProperties(1, 1);
            var request = new List <ApiVehicleCapabilitiesClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiVehicleCapabilitiesClientResponseModel> > result = await client.VehicleCapabilitiesBulkInsertAsync(request);

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

            context.Set <VehicleCapabilities>().ToList()[1].VehicleCapabilityId.Should().Be(1);
            context.Set <VehicleCapabilities>().ToList()[1].VehicleId.Should().Be(1);

            context.Set <VehicleCapabilities>().ToList()[2].VehicleCapabilityId.Should().Be(1);
            context.Set <VehicleCapabilities>().ToList()[2].VehicleId.Should().Be(1);
        }
Exemple #3
0
        public virtual ApiVehicleCapabilitiesClientRequestModel MapServerResponseToClientRequest(
            ApiVehicleCapabilitiesServerResponseModel response)
        {
            var request = new ApiVehicleCapabilitiesClientRequestModel();

            request.SetProperties(
                response.VehicleCapabilityId,
                response.VehicleId);
            return(request);
        }
Exemple #4
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiVehicleCapabilitiesModelMapper();
            var model  = new ApiVehicleCapabilitiesClientRequestModel();

            model.SetProperties(1, 1);
            ApiVehicleCapabilitiesClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.VehicleCapabilityId.Should().Be(1);
            response.VehicleId.Should().Be(1);
        }