コード例 #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 ApiRowVersionCheckServerModelMapper();
            ApplicationDbContext    context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IRowVersionCheckService service             = testServer.Host.Services.GetService(typeof(IRowVersionCheckService)) as IRowVersionCheckService;
            ApiRowVersionCheckServerResponseModel model = await service.Get(1);

            ApiRowVersionCheckClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));

            UpdateResponse <ApiRowVersionCheckClientResponseModel> updateResponse = await client.RowVersionCheckUpdateAsync(model.Id, request);

            context.Entry(context.Set <RowVersionCheck>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <RowVersionCheck>().ToList()[0].Name.Should().Be("B");
            context.Set <RowVersionCheck>().ToList()[0].RowVersion.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.RowVersion.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
        }
コード例 #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 ApiRowVersionCheckClientRequestModel();

            model.SetProperties("B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            var model2 = new ApiRowVersionCheckClientRequestModel();

            model2.SetProperties("C", Guid.Parse("8d721ec8-4c9d-632f-6f06-7f89cc14862c"));
            var request = new List <ApiRowVersionCheckClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiRowVersionCheckClientResponseModel> > result = await client.RowVersionCheckBulkInsertAsync(request);

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

            context.Set <RowVersionCheck>().ToList()[1].Name.Should().Be("B");
            context.Set <RowVersionCheck>().ToList()[1].RowVersion.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));

            context.Set <RowVersionCheck>().ToList()[2].Name.Should().Be("C");
            context.Set <RowVersionCheck>().ToList()[2].RowVersion.Should().Be(Guid.Parse("8d721ec8-4c9d-632f-6f06-7f89cc14862c"));
        }
コード例 #3
0
        public virtual ApiRowVersionCheckClientRequestModel MapServerResponseToClientRequest(
            ApiRowVersionCheckServerResponseModel response)
        {
            var request = new ApiRowVersionCheckClientRequestModel();

            request.SetProperties(
                response.Name,
                response.RowVersion);
            return(request);
        }
コード例 #4
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiRowVersionCheckModelMapper();
            var model  = new ApiRowVersionCheckClientRequestModel();

            model.SetProperties("A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiRowVersionCheckClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Name.Should().Be("A");
            response.RowVersion.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }