public void UpdatePaymentTransitionToNewState()
        {
            IClient commerceToolsClient = this.paymentsFixture.GetService <IClient>();
            var     payment             = this.paymentsFixture.CreatePayment();

            Assert.Null(payment.PaymentStatus.State);

            var initialPaymentState = this.paymentsFixture.CreateNewState(StateType.PaymentState, initial: true);

            Assert.NotNull(initialPaymentState.Id);

            TransitionStateUpdateAction transitionStateUpdateAction = new TransitionStateUpdateAction()
            {
                State = new Reference <State> {
                    Id = initialPaymentState.Id
                }
            };
            var updateActions = new List <UpdateAction <Payment> > {
                transitionStateUpdateAction
            };

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

            this.paymentsFixture.PaymentsToDelete.Add(retrievedPayment);

            Assert.NotNull(retrievedPayment.PaymentStatus.State);
            Assert.Equal(initialPaymentState.Id, retrievedPayment.PaymentStatus.State.Id);
        }
Beispiel #2
0
        public async Task UpdateReviewTransitionToNewState()
        {
            await WithState(client, stateDraft => DefaultStateDraftWithType(stateDraft, StateType.ReviewState),
                            async state =>
            {
                await WithUpdateableReview(client,
                                           async review =>
                {
                    var updateActions         = new List <UpdateAction <Review> >();
                    var transitionStateAction = new TransitionStateUpdateAction
                    {
                        State = state.ToKeyResourceIdentifier()
                    };
                    updateActions.Add(transitionStateAction);

                    var updatedReview = await client.ExecuteAsync(new UpdateByIdCommand <Review>(review, updateActions));
                    Assert.NotNull(updatedReview.State);
                    Assert.Equal(state.Id, updatedReview.State.Id);
                    return(updatedReview);
                });
            });
        }
Beispiel #3
0
        public async Task UpdatePaymentTransitionToNewState()
        {
            await WithState(client, stateDraft => DefaultStateDraftWithType(stateDraft, StateType.PaymentState),
                            async state =>
            {
                await WithUpdateablePayment(client,
                                            async payment =>
                {
                    Assert.Null(payment.PaymentStatus.State);
                    var action = new TransitionStateUpdateAction
                    {
                        State = state.ToReference()
                    };

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

                    Assert.NotNull(updatedPayment.PaymentStatus);
                    Assert.Equal(state.Id, updatedPayment.PaymentStatus.State.Id);
                    return(updatedPayment);
                });
            });
        }