Пример #1
0
        public void FindNext_Returns_Null_When_The_Last_Node_Is_Supplied()
        {
            var node = new RequestChainNode(firstRequestChainPart.GetType());
            var next = findNextRequestChainPart.FindNext(node, firstRequestChainPart, resolveDependencies, request);

            next.ShouldBeNull();
        }
Пример #2
0
        public void AddAfter(RequestChainNode requestChainPart)
        {
            if (requestChainPart == null) return;

            requestChainPart.Previous = this;
            requestChainPart.Next = Next;
            Next = requestChainPart;
        }
Пример #3
0
        public void FindNext_Returns_Second_When_First_Is_Supplied()
        {
            var node = new RequestChainNode(firstRequestChainPart.GetType());
            node.AddAfter(new RequestChainNode(thirdRequestChainPart.GetType()));
            node.AddAfter(new RequestChainNode(secondRequestChainPart.GetType()));

            var next = findNextRequestChainPart.FindNext(node, firstRequestChainPart, resolveDependencies, request);

            next.ShouldEqual(secondRequestChainPart);
        }
Пример #4
0
        public void FindNext_Returns_ThirdNode_When_Second_Node_Isnt_Used()
        {
            secondRequestChainPart.ShouldUseValue = false;

            var node = new RequestChainNode(firstRequestChainPart.GetType());
            node.AddAfter(new RequestChainNode(thirdRequestChainPart.GetType()));
            node.AddAfter(new RequestChainNode(secondRequestChainPart.GetType()));

            var next = findNextRequestChainPart.FindNext(node, firstRequestChainPart, resolveDependencies, request);

            next.ShouldEqual(thirdRequestChainPart);
        }
Пример #5
0
        public void FindNext_Returns_Null_When_Second_Is_Supplied_And_Third_Isnt_Used()
        {
            thirdRequestChainPart.ShouldUseValue = false;

            var node = new RequestChainNode(firstRequestChainPart.GetType());
            node.AddAfter(new RequestChainNode(thirdRequestChainPart.GetType()));
            node.AddAfter(new RequestChainNode(secondRequestChainPart.GetType()));

            var next = findNextRequestChainPart.FindNext(node, secondRequestChainPart, resolveDependencies, request);

            next.ShouldBeNull();
        }
Пример #6
0
        public IRequestChainPart FindNext(RequestChainNode firstNode, IRequestChainPart requestChainPart, IResolveDependencies resolveDependencies, IRequest request)
        {
            if (requestChainPart != null)
            {
                firstNode = firstNode.Find(requestChainPart.GetType()).Next;
                if (firstNode == null)
                    return null;
            }

            var currentRequestChainPart = (IRequestChainPart)resolveDependencies.Resolve(firstNode.Item);
            while (!currentRequestChainPart.ShouldUse(request))
            {
                firstNode = firstNode.Find(currentRequestChainPart.GetType()).Next;
                if (firstNode == null) return null;

                currentRequestChainPart = (IRequestChainPart)resolveDependencies.Resolve(firstNode.Item);
            }

            return currentRequestChainPart;
        }