Beispiel #1
0
        public async Task UpdatePaymentAddInterfaceInteraction()
        {
            var fields = CreateNewFields();

            await WithType(client, async type =>
            {
                await WithUpdateablePayment(client,
                                            async payment =>
                {
                    Assert.Empty(payment.InterfaceInteractions);

                    var action = new AddInterfaceInteractionUpdateAction
                    {
                        Type   = type.ToKeyResourceIdentifier(),
                        Fields = fields
                    };

                    var updatedPayment = await client
                                         .ExecuteAsync(payment.UpdateByKey(actions => actions.AddUpdate(action)));

                    Assert.Single(updatedPayment.InterfaceInteractions);
                    Assert.Equal(type.Id, updatedPayment.InterfaceInteractions[0].Type.Id);
                    return(updatedPayment);
                });
            });
        }
        public void UpdatePaymentAddInterfaceInteraction()
        {
            IClient commerceToolsClient = this.paymentsFixture.GetService <IClient>();
            var     payment             = this.paymentsFixture.CreatePayment();

            Assert.Empty(payment.InterfaceInteractions);

            var type   = this.paymentsFixture.CreateNewType();
            var fields = this.paymentsFixture.CreateNewFields();

            AddInterfaceInteractionUpdateAction addInterfaceInteractionUpdateAction = new AddInterfaceInteractionUpdateAction()
            {
                Type = new ResourceIdentifier <Type> {
                    Id = type.Id
                },
                Fields = fields
            };
            var updateActions = new List <UpdateAction <Payment> > {
                addInterfaceInteractionUpdateAction
            };

            var retrievedPayment = commerceToolsClient
                                   .ExecuteAsync(new UpdateByIdCommand <Payment>(payment.Id, payment.Version, updateActions))
                                   .Result;

            this.paymentsFixture.PaymentsToDelete.Add(retrievedPayment);

            Assert.Single(retrievedPayment.InterfaceInteractions);
            Assert.Equal(type.Id, retrievedPayment.InterfaceInteractions[0].Type.Id);
        }