Ejemplo n.º 1
0
        protected override IEnumerable <WampMessage <MockRaw> > FindResponses(WampMessage <MockRaw> message,
                                                                              WampMessage <MockRaw> request)
        {
            long?id = message.GetRequestId();

            long?recordedId = request.GetRequestId();

            WampMessage <MockRaw>[] messages =
                mMessages.Where(x => x.GetRequestId() == recordedId &&
                                x.MessageType != request.MessageType)
                .ToArray();

            foreach (WampMessage <MockRaw> currentMessage in messages)
            {
                SetRequestId(currentMessage, id);
            }

            return(messages);
        }
Ejemplo n.º 2
0
        public override void Record(WampMessage <MockRaw> message)
        {
            base.Record(message);

            string argumentName;

            if (mMessageTypeToParameter.TryGetValue(message.MessageType, out argumentName))
            {
                int relevantIndex =
                    GetIndex(message, argumentName).Value;

                long?newId = GetArgumentValue(message, relevantIndex);

                long?requestId = message.GetRequestId();

                WampMessage <MockRaw> originalCall =
                    mCalls.FirstOrDefault(x => x.GetRequestId() == requestId &&
                                          x.MessageType == message.MessageType);

                long?originalId = GetArgumentValue(originalCall, relevantIndex);

                foreach (WampMessage <MockRaw> call in mCalls)
                {
                    int?currentIndex =
                        GetIndex(call, argumentName);

                    if (currentIndex != null)
                    {
                        long?current = GetArgumentValue(call, currentIndex.Value);

                        if (current == originalId)
                        {
                            call.Arguments[currentIndex.Value] = new MockRaw(newId);
                        }
                    }
                }
            }
        }