Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public virtual ApiVehicleCapabilitiesClientRequestModel MapServerResponseToClientRequest(
            ApiVehicleCapabilitiesServerResponseModel response)
        {
            var request = new ApiVehicleCapabilitiesClientRequestModel();

            request.SetProperties(
                response.VehicleCapabilityId,
                response.VehicleId);
            return(request);
        }
Ejemplo n.º 4
0
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiVehicleCapabilitiesModelMapper();
            var model  = new ApiVehicleCapabilitiesClientResponseModel();

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

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