예제 #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 ApiSaleTicketsServerModelMapper();
            ApplicationDbContext context            = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ISaleTicketsService  service            = testServer.Host.Services.GetService(typeof(ISaleTicketsService)) as ISaleTicketsService;
            ApiSaleTicketsServerResponseModel model = await service.Get(1);

            ApiSaleTicketsClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiSaleTicketsClientResponseModel> updateResponse = await client.SaleTicketsUpdateAsync(model.Id, request);

            context.Entry(context.Set <SaleTickets>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <SaleTickets>().ToList()[0].SaleId.Should().Be(1);
            context.Set <SaleTickets>().ToList()[0].TicketId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.SaleId.Should().Be(1);
            updateResponse.Record.TicketId.Should().Be(1);
        }
예제 #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 ApiSaleTicketsClientRequestModel();

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

            model2.SetProperties(1, 1);
            var request = new List <ApiSaleTicketsClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiSaleTicketsClientResponseModel> > result = await client.SaleTicketsBulkInsertAsync(request);

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

            context.Set <SaleTickets>().ToList()[1].SaleId.Should().Be(1);
            context.Set <SaleTickets>().ToList()[1].TicketId.Should().Be(1);

            context.Set <SaleTickets>().ToList()[2].SaleId.Should().Be(1);
            context.Set <SaleTickets>().ToList()[2].TicketId.Should().Be(1);
        }
예제 #3
0
        public virtual ApiSaleTicketsClientRequestModel MapServerResponseToClientRequest(
            ApiSaleTicketsServerResponseModel response)
        {
            var request = new ApiSaleTicketsClientRequestModel();

            request.SetProperties(
                response.SaleId,
                response.TicketId);
            return(request);
        }
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiSaleTicketsModelMapper();
            var model  = new ApiSaleTicketsClientRequestModel();

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

            response.Should().NotBeNull();
            response.SaleId.Should().Be(1);
            response.TicketId.Should().Be(1);
        }