コード例 #1
0
        /// <summary>
        /// Get State Draft
        /// </summary>
        /// <param name="stateKey">key of the state</param>
        /// <param name="stateType">type of the state</param>
        /// <param name="initial">is this initial state</param>
        /// <returns></returns>
        public StateDraft GetStateDraft(string stateKey, StateType stateType = StateType.ProductState, bool initial = true, IReference <State> transitionTo = null)
        {
            var stateDraft = new StateDraft
            {
                Key  = stateKey,
                Name = new LocalizedString()
                {
                    { "en", TestingUtility.RandomString(10) }
                },
                Description = new LocalizedString()
                {
                    { "en", TestingUtility.RandomString(20) }
                },
                Initial = initial,
                Type    = stateType
            };

            if (transitionTo != null)
            {
                stateDraft.Transitions = new List <IReference <State> > {
                    transitionTo
                };
            }
            return(stateDraft);
        }
コード例 #2
0
        public State CreateState(StateDraft stateDraft)
        {
            IClient commerceToolsClient = this.GetService <IClient>();
            State   state = commerceToolsClient.ExecuteAsync(new CreateCommand <State>(stateDraft)).Result;

            return(state);
        }
コード例 #3
0
        public static StateDraft DefaultStateDraftWithType(StateDraft draft, StateType stateType)
        {
            var stateDraft = DefaultStateDraft(draft);

            stateDraft.Type = stateType;
            return(stateDraft);
        }
コード例 #4
0
        public static StateDraft DefaultStateDraftWithRoles(StateDraft draft, List <StateRole> roles)
        {
            var stateDraft = DefaultStateDraftWithType(draft, StateType.LineItemState);

            stateDraft.Roles = roles;
            return(stateDraft);
        }
コード例 #5
0
        public static StateDraft DefaultStateDraftWithKey(StateDraft draft, string key)
        {
            var stateDraft = DefaultStateDraft(draft);

            stateDraft.Key = key;
            return(stateDraft);
        }
        public void CreateState()
        {
            IClient    commerceToolsClient = this.statesFixture.GetService <IClient>();
            string     stateKey            = $"Key-{TestingUtility.RandomInt()}";
            StateDraft stateDraft          = this.statesFixture.GetStateDraft(stateKey);
            State      state = commerceToolsClient
                               .ExecuteAsync(new CreateCommand <State>(stateDraft)).Result;

            this.statesFixture.StatesToDelete.Add(state);
            Assert.Equal(stateDraft.Key, state.Key);
        }
コード例 #7
0
        public static StateDraft DefaultStateDraft(StateDraft stateDraft)
        {
            var randomInt = TestingUtility.RandomInt();

            stateDraft.Initial = true;
            stateDraft.Name    = new LocalizedString()
            {
                { "en", $"State_Name_{randomInt}" }
            };
            stateDraft.Description = new LocalizedString()
            {
                { "en", $"State_Description_{randomInt}" }
            };
            stateDraft.Key  = $"Key{randomInt}";
            stateDraft.Type = StateType.ProductState;
            return(stateDraft);
        }