예제 #1
0
 public TokenVerifier()
 {
     StartState    = new EquationStartState(this);
     OperandState  = new OperandTokenState(this);
     OperatorState = new OperatorTokenState(this);
     CurrentState  = StartState;
 }
예제 #2
0
        /// <summary>
        /// Initializes the verifier's state based on its inputs
        /// </summary>
        /// <param name="continuation">The async continuation</param>
        protected virtual void InitializeState(IAsyncContinuation continuation)
        {
            this.State = new VerifierState();

            this.State.UsedOptions = this.Input.Options.HasValue ? this.Input.Options.Value : this.Input.Context.SaveChangesDefaultOptions.ToTestEnum();

            this.State.ContextDataBeforeChanges = this.Input.ContextData.Clone();

            this.State.Response = null;
            this.State.EnumeratedOperationResponses.Clear();

            this.State.CachedPropertyValuesBeforeSave.Clear();
            foreach (var entityDescriptorData in this.State.ContextDataBeforeChanges.EntityDescriptorsData.Where(e => e.Entity != null))
            {
                var entityType = this.ModelSchema.EntityTypes.Single(t => t.FullName == entityDescriptorData.EntityClrType.FullName);
                this.State.CachedPropertyValuesBeforeSave[entityDescriptorData.Entity] = this.ObjectServices.GetPropertiesValues(entityDescriptorData.Entity, entityType);
            }

            this.ServerStateVerifier.InitializeExpectedChanges(this.Input.ContextData, this.State.CachedPropertyValuesBeforeSave);

            continuation.Continue();
        }
예제 #3
0
        /// <summary>
        /// Executes SaveChanges method on the specified context and verifies the results.
        /// </summary>
        /// <param name="continuation">The async continuation</param>
        /// <param name="contextData">The context data.</param>
        /// <param name="context">The context to verify SaveChanges.</param>
        /// <param name="options">The options for saving changes. Passing null will use the context's default.</param>
        /// <param name="onCompletion">callback for when save changes verification completes</param>
        public virtual void VerifySaveChanges(IAsyncContinuation continuation, DataServiceContextData contextData, DSClient.DataServiceContext context, SaveChangesOptions?options, Action <IAsyncContinuation, DSClient.DataServiceResponse> onCompletion)
        {
            ExceptionUtilities.CheckArgumentNotNull(contextData, "contextData");
            ExceptionUtilities.CheckArgumentNotNull(context, "context");
            ExceptionUtilities.CheckArgumentNotNull(onCompletion, "onCompletion");
            ExceptionUtilities.CheckAllRequiredDependencies(this);

            // ensure that two calls are not being processed in parallel
            ExceptionUtilities.Assert(this.Input == null, "Input was not null, possibly due to simultaneous calls or using the wrong async continuation");
            ExceptionUtilities.Assert(this.State == null, "State was not null, possibly due to simultaneous calls or using the wrong async continuation");
            continuation = continuation.OnContinueOrFail(
                () =>
            {
                this.Input = null;
                this.State = null;
            });

            this.Input = new VerifierInput()
            {
                ContextData  = contextData,
                Context      = context,
                Options      = options,
                OnCompletion = onCompletion,
            };

            AsyncHelpers.RunActionSequence(
                continuation,
                this.InitializeState,
                this.VerifyContextState,
                this.CallProductApi,
                this.VerifyRequests,
                this.VerifyResponse,
                this.VerifyContextState,
                this.VerifyServerState,
                this.Complete);
        }