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 ApiPostHistoryTypeClientRequestModel();

            model.SetProperties("B");
            var model2 = new ApiPostHistoryTypeClientRequestModel();

            model2.SetProperties("C");
            var request = new List <ApiPostHistoryTypeClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiPostHistoryTypeClientResponseModel> > result = await client.PostHistoryTypeBulkInsertAsync(request);

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

            context.Set <PostHistoryType>().ToList()[1].RwType.Should().Be("B");

            context.Set <PostHistoryType>().ToList()[2].RwType.Should().Be("C");
        }
        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 ApiPostHistoryTypeServerModelMapper();
            ApplicationDbContext    context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IPostHistoryTypeService service             = testServer.Host.Services.GetService(typeof(IPostHistoryTypeService)) as IPostHistoryTypeService;
            ApiPostHistoryTypeServerResponseModel model = await service.Get(1);

            ApiPostHistoryTypeClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B");

            UpdateResponse <ApiPostHistoryTypeClientResponseModel> updateResponse = await client.PostHistoryTypeUpdateAsync(model.Id, request);

            context.Entry(context.Set <PostHistoryType>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <PostHistoryType>().ToList()[0].RwType.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.RwType.Should().Be("B");
        }
Ejemplo n.º 3
0
        public virtual ApiPostHistoryTypeClientRequestModel MapServerResponseToClientRequest(
            ApiPostHistoryTypeServerResponseModel response)
        {
            var request = new ApiPostHistoryTypeClientRequestModel();

            request.SetProperties(
                response.RwType);
            return(request);
        }
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiPostHistoryTypeModelMapper();
            var model  = new ApiPostHistoryTypeClientResponseModel();

            model.SetProperties(1, "A");
            ApiPostHistoryTypeClientRequestModel response = mapper.MapClientResponseToRequest(model);

            response.Should().NotBeNull();
            response.RwType.Should().Be("A");
        }