public void Init()
 {
     Fixture     = GetFixture();
     representor = Fixture.Create <CrichtonRepresentor>();
     sut         = new NavigateToRepresentorQueryStep(representor);
     requestor   = MockRepository.GenerateMock <ITransitionRequestHandler>();
 }
        /// <summary>
        /// Initializes a new instance of the CrichtonClient class.
        /// </summary>
        /// <param name="transitionRequestHandler">the transitionRequestHandler</param>
        public CrichtonClient(ITransitionRequestHandler transitionRequestHandler)
        {
            if (transitionRequestHandler == null)
            {
                throw new ArgumentNullException("transitionRequestHandler");
            }

            TransitionRequestHandler = transitionRequestHandler;
        }
Пример #3
0
        public void Init()
        {
            messageHandler = new FakeHttpMessageHandler();
            baseUri        = new Uri("http://www.my-awesome-company.com");
            client         = new HttpClient(messageHandler);
            serializer     = MockRepository.GenerateMock <ISerializer>();
            requestHandler = MockRepository.GenerateMock <ITransitionRequestHandler>();

            sut     = new CrichtonClient(requestHandler);
            Fixture = GetFixture();
        }
        /// <summary>
        /// Initializes a new instance of the CrichtonClient class.
        /// </summary>
        /// <param name="client">the client</param>
        /// <param name="serializer">the serializer</param>
        public CrichtonClient(HttpClient client, ISerializer serializer)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (client.BaseAddress == null)
            {
                throw new ArgumentException("HttpClient.BaseAddress must not be null.");
            }
            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            TransitionRequestHandler = new HttpClientTransitionRequestHandler(client, serializer);
        }
Пример #5
0
        /// <summary>
        /// Execute the query
        /// </summary>
        /// <param name="requestHandler">the requestHandler</param>
        /// <returns>task including a CrichtonRepresentor</returns>
        public async Task <CrichtonRepresentor> ExecuteAsync(ITransitionRequestHandler requestHandler)
        {
            if (requestHandler == null)
            {
                throw new ArgumentNullException("requestHandler");
            }

            CrichtonRepresentor representor = null;

            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (var step in Steps)
            {
                representor = await step.ExecuteAsync(representor, requestHandler);
            }

            return(representor);
        }
Пример #6
0
        /// <summary>
        /// Executes the representor
        /// </summary>
        /// <param name="currentRepresentor">the currentRepresentor</param>
        /// <param name="transitionRequestHandler">the transitionRequestHandler</param>
        /// <returns>crichton representor</returns>
        public Task <CrichtonRepresentor> ExecuteAsync(CrichtonRepresentor currentRepresentor, ITransitionRequestHandler transitionRequestHandler)
        {
            if (currentRepresentor == null)
            {
                throw new ArgumentNullException("currentRepresentor");
            }
            if (transitionRequestHandler == null)
            {
                throw new ArgumentNullException("transitionRequestHandler");
            }

            var selfTransition = new CrichtonTransition()
            {
                Uri = currentRepresentor.SelfLink
            };

            return(transitionRequestHandler.RequestTransitionAsync(selfTransition));
        }
 /// <summary>
 /// Executes the representor
 /// </summary>
 /// <param name="currentRepresentor">the currentRepresentor</param>
 /// <param name="transitionRequestHandler">the transitionRequestHandler</param>
 /// <returns>crichton representor</returns>
 public async Task <CrichtonRepresentor> ExecuteAsync(CrichtonRepresentor currentRepresentor, ITransitionRequestHandler transitionRequestHandler)
 {
     return(Representor);
 }
        /// <summary>
        /// Executes the representor
        /// </summary>
        /// <param name="currentRepresentor">the currentRepresentor</param>
        /// <param name="transitionRequestHandler">the transitionRequestHandler</param>
        /// <returns>crichton representor</returns>
        public Task <CrichtonRepresentor> ExecuteAsync(CrichtonRepresentor currentRepresentor, ITransitionRequestHandler transitionRequestHandler)
        {
            var transition = LocateTransition(currentRepresentor);

            return(transitionRequestHandler.RequestTransitionAsync(transition, Data));
        }
Пример #9
0
        /// <summary>
        /// Executes the representor
        /// </summary>
        /// <param name="currentRepresentor">the currentRepresentor</param>
        /// <param name="transitionRequestHandler">the transitionRequestHandler</param>
        /// <returns>crichton representor</returns>
        public Task <CrichtonRepresentor> ExecuteAsync(CrichtonRepresentor currentRepresentor, ITransitionRequestHandler transitionRequestHandler)
        {
            var transition = new CrichtonTransition()
            {
                Uri = Url
            };

            return(transitionRequestHandler.RequestTransitionAsync(transition));
        }
        /// <summary>
        /// Executes the representor
        /// </summary>
        /// <param name="currentRepresentor">the currentRepresentor</param>
        /// <param name="transitionRequestHandler">the transitionRequestHandler</param>
        /// <returns>crichton representor</returns>
        public Task <CrichtonRepresentor> ExecuteAsync(CrichtonRepresentor currentRepresentor, ITransitionRequestHandler transitionRequestHandler)
        {
            if (currentRepresentor == null)
            {
                throw new ArgumentNullException("currentRepresentor");
            }
            if (transitionRequestHandler == null)
            {
                throw new ArgumentNullException("transitionRequestHandler");
            }

            var transition = LocateTransition(currentRepresentor);

            return(transitionRequestHandler.RequestTransitionAsync(transition));
        }