Ejemplo n.º 1
0
        public void StartInvocation(params object[] requestArgs)
        {
            int currentDepth = TestFlaskContext.CurrentDepth;

            string parentInstanceHashCode = TestFlaskContext.InvocationParentTable.ContainsKey(currentDepth) ? TestFlaskContext.InvocationParentTable[currentDepth] : null;

            TestFlaskContext.CurrentDepth++;

            var step = TestFlaskContext.RequestedStep;

            requestedInvocation = new Invocation();

            requestedInvocation.Depth = TestFlaskContext.CurrentDepth;

            requestedInvocation.ScenarioNo = step.ScenarioNo;
            requestedInvocation.ProjectKey = step.ProjectKey;
            requestedInvocation.StepNo     = step.StepNo;

            requestedInvocation.IsReplayable         = requestedInvocation.Depth > 1; //root invocation not playable by default
            requestedInvocation.InvocationSignature  = methodSignature;
            requestedInvocation.RequestDisplayInfo   = requestDisplayInfo;
            requestedInvocation.RequestIdentifierKey = requestIdentifierKey;
            requestedInvocation.Request = JsonConvert.SerializeObject(requestArgs);

            //set hash codes
            requestedInvocation.HashCode     = requestedInvocation.GetInvocationHashCode();
            requestedInvocation.DeepHashCode = requestedInvocation.GetInvocationDeepHashCode();

            //need to find an invocation index on that depth level using something like testFlaskContext.InvocationDepthTable (deep hash code)
            var invocationDepthTable = TestFlaskContext.InvocationDepthTable;

            if (!invocationDepthTable.ContainsKey(requestedInvocation.DeepHashCode))
            {
                invocationDepthTable[requestedInvocation.DeepHashCode] = 0;
                requestedInvocation.InvocationIndex = 0;
            }
            else
            {
                invocationDepthTable[requestedInvocation.DeepHashCode] = invocationDepthTable[requestedInvocation.DeepHashCode] + 1;
                requestedInvocation.InvocationIndex = invocationDepthTable[requestedInvocation.DeepHashCode];
            }

            requestedInvocation.InstanceHashCode       = requestedInvocation.GetInvocationInstanceHashCode();
            requestedInvocation.ParentInstanceHashCode = parentInstanceHashCode;

            //make this invocation latest parent for the current depth
            TestFlaskContext.InvocationParentTable[TestFlaskContext.CurrentDepth] = requestedInvocation.InstanceHashCode;
        }