Пример #1
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiDestinationClientResponseModel> response = await client.DestinationAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].CountryId.Should().Be(1);
            response[0].Id.Should().Be(1);
            response[0].Name.Should().Be("A");
            response[0].Order.Should().Be(1);
        }
Пример #2
0
        public virtual async void TestGetFound()
        {
            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;

            ApiPipelineStatusClientResponseModel response = await client.PipelineStatusGetAsync(1);

            response.Should().NotBeNull();
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiPipelineStepStepRequirementClientResponseModel> response = await client.PipelineStepStepRequirementAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Details.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].PipelineStepId.Should().Be(1);
            response[0].RequirementMet.Should().Be(true);
        }
Пример #4
0
        public virtual async void TestByEmployeeIdFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiCustomerCommunicationClientResponseModel> response = await client.ByCustomerCommunicationByEmployeeId(1);

            response.Should().NotBeEmpty();
            response[0].CustomerId.Should().Be(1);
            response[0].DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].EmployeeId.Should().Be(1);
            response[0].Id.Should().Be(1);
            response[0].Notes.Should().Be("A");
        }
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiEmployeeClientResponseModel> response = await client.EmployeeAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].FirstName.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].IsSalesPerson.Should().Be(true);
            response[0].IsShipper.Should().Be(true);
            response[0].LastName.Should().Be("A");
        }
Пример #6
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 ApiSaleClientRequestModel();

            model.SetProperties(2m, 2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2);
            var model2 = new ApiSaleClientRequestModel();

            model2.SetProperties(3m, 3, "C", 1, DateTime.Parse("1/1/1989 12:00:00 AM"), 3);
            var request = new List <ApiSaleClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiSaleClientResponseModel> > result = await client.SaleBulkInsertAsync(request);

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

            context.Set <Sale>().ToList()[1].Amount.Should().Be(2m);
            context.Set <Sale>().ToList()[1].CutomerId.Should().Be(2);
            context.Set <Sale>().ToList()[1].Note.Should().Be("B");
            context.Set <Sale>().ToList()[1].PetId.Should().Be(1);
            context.Set <Sale>().ToList()[1].SaleDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Sale>().ToList()[1].SalesPersonId.Should().Be(2);

            context.Set <Sale>().ToList()[2].Amount.Should().Be(3m);
            context.Set <Sale>().ToList()[2].CutomerId.Should().Be(3);
            context.Set <Sale>().ToList()[2].Note.Should().Be("C");
            context.Set <Sale>().ToList()[2].PetId.Should().Be(1);
            context.Set <Sale>().ToList()[2].SaleDate.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <Sale>().ToList()[2].SalesPersonId.Should().Be(3);
        }
        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 ApiAirTransportClientRequestModel();

            model.SetProperties(2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"));
            var model2 = new ApiAirTransportClientRequestModel();

            model2.SetProperties(3, "C", 1, DateTime.Parse("1/1/1989 12:00:00 AM"), 3, DateTime.Parse("1/1/1989 12:00:00 AM"));
            var request = new List <ApiAirTransportClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiAirTransportClientResponseModel> > result = await client.AirTransportBulkInsertAsync(request);

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

            context.Set <AirTransport>().ToList()[1].AirlineId.Should().Be(2);
            context.Set <AirTransport>().ToList()[1].FlightNumber.Should().Be("B");
            context.Set <AirTransport>().ToList()[1].HandlerId.Should().Be(1);
            context.Set <AirTransport>().ToList()[1].LandDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <AirTransport>().ToList()[1].PipelineStepId.Should().Be(2);
            context.Set <AirTransport>().ToList()[1].TakeoffDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));

            context.Set <AirTransport>().ToList()[2].AirlineId.Should().Be(3);
            context.Set <AirTransport>().ToList()[2].FlightNumber.Should().Be("C");
            context.Set <AirTransport>().ToList()[2].HandlerId.Should().Be(1);
            context.Set <AirTransport>().ToList()[2].LandDate.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
            context.Set <AirTransport>().ToList()[2].PipelineStepId.Should().Be(3);
            context.Set <AirTransport>().ToList()[2].TakeoffDate.Should().Be(DateTime.Parse("1/1/1989 12:00:00 AM"));
        }
Пример #8
0
        public virtual async void TestGetFound()
        {
            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;

            ApiCustomerCommunicationClientResponseModel response = await client.CustomerCommunicationGetAsync(1);

            response.Should().NotBeNull();
            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Notes.Should().Be("A");
        }
Пример #9
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiSaleClientResponseModel> response = await client.SaleAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Amount.Should().Be(1m);
            response[0].CutomerId.Should().Be(1);
            response[0].Id.Should().Be(1);
            response[0].Note.Should().Be("A");
            response[0].PetId.Should().Be(1);
            response[0].SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].SalesPersonId.Should().Be(1);
        }
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiAirTransportClientResponseModel> response = await client.AirTransportAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].AirlineId.Should().Be(1);
            response[0].FlightNumber.Should().Be("A");
            response[0].HandlerId.Should().Be(1);
            response[0].Id.Should().Be(1);
            response[0].LandDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].PipelineStepId.Should().Be(1);
            response[0].TakeoffDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
Пример #11
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 ApiSaleServerModelMapper();
            ApplicationDbContext       context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ISaleService               service = testServer.Host.Services.GetService(typeof(ISaleService)) as ISaleService;
            ApiSaleServerResponseModel model   = await service.Get(1);

            ApiSaleClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(2m, 2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2);

            UpdateResponse <ApiSaleClientResponseModel> updateResponse = await client.SaleUpdateAsync(model.Id, request);

            context.Entry(context.Set <Sale>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Sale>().ToList()[0].Amount.Should().Be(2m);
            context.Set <Sale>().ToList()[0].CutomerId.Should().Be(2);
            context.Set <Sale>().ToList()[0].Note.Should().Be("B");
            context.Set <Sale>().ToList()[0].PetId.Should().Be(1);
            context.Set <Sale>().ToList()[0].SaleDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Sale>().ToList()[0].SalesPersonId.Should().Be(2);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Amount.Should().Be(2m);
            updateResponse.Record.CutomerId.Should().Be(2);
            updateResponse.Record.Note.Should().Be("B");
            updateResponse.Record.PetId.Should().Be(1);
            updateResponse.Record.SaleDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.SalesPersonId.Should().Be(2);
        }
        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 ApiAirTransportServerModelMapper();
            ApplicationDbContext context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IAirTransportService service             = testServer.Host.Services.GetService(typeof(IAirTransportService)) as IAirTransportService;
            ApiAirTransportServerResponseModel model = await service.Get(1);

            ApiAirTransportClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM"));

            UpdateResponse <ApiAirTransportClientResponseModel> updateResponse = await client.AirTransportUpdateAsync(model.Id, request);

            context.Entry(context.Set <AirTransport>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <AirTransport>().ToList()[0].AirlineId.Should().Be(2);
            context.Set <AirTransport>().ToList()[0].FlightNumber.Should().Be("B");
            context.Set <AirTransport>().ToList()[0].HandlerId.Should().Be(1);
            context.Set <AirTransport>().ToList()[0].LandDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <AirTransport>().ToList()[0].PipelineStepId.Should().Be(2);
            context.Set <AirTransport>().ToList()[0].TakeoffDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.AirlineId.Should().Be(2);
            updateResponse.Record.FlightNumber.Should().Be("B");
            updateResponse.Record.HandlerId.Should().Be(1);
            updateResponse.Record.LandDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.PipelineStepId.Should().Be(2);
            updateResponse.Record.TakeoffDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
        }
Пример #13
0
        public virtual async void TestCreate()
        {
            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 ApiPipelineStatusClientRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiPipelineStatusClientResponseModel> result = await client.PipelineStatusCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <PipelineStatus>().ToList()[1].Name.Should().Be("B");

            result.Record.Name.Should().Be("B");
        }
Пример #14
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 ApiHandlerClientRequestModel();

            model.SetProperties(2, "B", "B", "B", "B");
            var model2 = new ApiHandlerClientRequestModel();

            model2.SetProperties(3, "C", "C", "C", "C");
            var request = new List <ApiHandlerClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiHandlerClientResponseModel> > result = await client.HandlerBulkInsertAsync(request);

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

            context.Set <Handler>().ToList()[1].CountryId.Should().Be(2);
            context.Set <Handler>().ToList()[1].Email.Should().Be("B");
            context.Set <Handler>().ToList()[1].FirstName.Should().Be("B");
            context.Set <Handler>().ToList()[1].LastName.Should().Be("B");
            context.Set <Handler>().ToList()[1].Phone.Should().Be("B");

            context.Set <Handler>().ToList()[2].CountryId.Should().Be(3);
            context.Set <Handler>().ToList()[2].Email.Should().Be("C");
            context.Set <Handler>().ToList()[2].FirstName.Should().Be("C");
            context.Set <Handler>().ToList()[2].LastName.Should().Be("C");
            context.Set <Handler>().ToList()[2].Phone.Should().Be("C");
        }
Пример #15
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 ApiHandlerServerModelMapper();
            ApplicationDbContext          context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IHandlerService               service = testServer.Host.Services.GetService(typeof(IHandlerService)) as IHandlerService;
            ApiHandlerServerResponseModel model   = await service.Get(1);

            ApiHandlerClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiHandlerClientResponseModel> updateResponse = await client.HandlerUpdateAsync(model.Id, request);

            context.Entry(context.Set <Handler>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Handler>().ToList()[0].CountryId.Should().Be(2);
            context.Set <Handler>().ToList()[0].Email.Should().Be("B");
            context.Set <Handler>().ToList()[0].FirstName.Should().Be("B");
            context.Set <Handler>().ToList()[0].LastName.Should().Be("B");
            context.Set <Handler>().ToList()[0].Phone.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CountryId.Should().Be(2);
            updateResponse.Record.Email.Should().Be("B");
            updateResponse.Record.FirstName.Should().Be("B");
            updateResponse.Record.LastName.Should().Be("B");
            updateResponse.Record.Phone.Should().Be("B");
        }
        public virtual async void TestGetFound()
        {
            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;

            ApiAirTransportClientResponseModel response = await client.AirTransportGetAsync(1);

            response.Should().NotBeNull();
            response.AirlineId.Should().Be(1);
            response.FlightNumber.Should().Be("A");
            response.HandlerId.Should().Be(1);
            response.Id.Should().Be(1);
            response.LandDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PipelineStepId.Should().Be(1);
            response.TakeoffDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }