Ejemplo n.º 1
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiChainServerModelMapper();
            var model  = new ApiChainServerResponseModel();

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

            response.Should().NotBeNull();
            response.ChainStatusId.Should().Be(1);
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Name.Should().Be("A");
            response.TeamId.Should().Be(1);
        }
Ejemplo n.º 2
0
        public void CreatePatch()
        {
            var mapper = new ApiChainServerModelMapper();
            var model  = new ApiChainServerRequestModel();

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

            JsonPatchDocument <ApiChainServerRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiChainServerRequestModel();

            patch.ApplyTo(response);
            response.ChainStatusId.Should().Be(1);
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Name.Should().Be("A");
            response.TeamId.Should().Be(1);
        }
Ejemplo n.º 3
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 ApiChainServerModelMapper();
            ApplicationDbContext        context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IChainService               service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService;
            ApiChainServerResponseModel model   = await service.Get(1);

            ApiChainClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiChainClientResponseModel> updateResponse = await client.ChainUpdateAsync(model.Id, request);

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

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.ChainStatusId.Should().Be(1);
            updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.TeamId.Should().Be(1);
        }