public void SegmentProperty()
        {
            dynamic proxy = new TestProxy("http://example.com");
            dynamic chain = proxy.segment1;

            Assert.AreEqual("http://example.com/segment1", chain);
        }
        public void TwoSegmentProperties()
        {
            dynamic proxy = new TestProxy("http://example.com");
            dynamic chain = proxy.segment1.segment2;

            Assert.AreEqual("http://example.com/segment1/segment2", chain);
        }
        public void EscapeTwoSequentialSegmentsThenProperty()
        {
            dynamic proxy = new TestProxy("http://example.com");
            dynamic chain = proxy.segment1("escaped")("escaped2").segment2;

            Assert.AreEqual("http://example.com/segment1/escaped/escaped2/segment2", chain);
        }
        public void EscapeSegmentAsInvokeContinueChaining()
        {
            dynamic proxy    = new TestProxy("http://example.com");
            dynamic segment1 = proxy.segment1;
            dynamic chain    = segment1("escaped")("escaped2").segment2;

            Assert.AreEqual("http://example.com/segment1/escaped/escaped2/segment2", chain);
        }
        public void EscapeSegmentAsInvoke()
        {
            dynamic proxy    = new TestProxy("http://example.com");
            dynamic segment1 = proxy.segment1;
            dynamic chain    = segment1("escaped");

            Assert.AreEqual("http://example.com/segment1/escaped", chain);
        }
        public void EscapeSegment()
        {
            dynamic proxy = new TestProxy("http://example.com");
            dynamic chain = proxy.segment1("escaped").segment2;

            string s = chain.ToString();

            Assert.AreEqual("http://example.com/segment1/escaped/segment2", chain);
        }
        public async Task ReturnTypePassesThrough()
        {
            using (var source = new CancellationTokenSource())
            {
                dynamic proxy   = new TestProxy("http://example.com");
                dynamic expando = await proxy.get(typeof(ExpandoObject), name : "value");

                Assert.AreEqual(typeof(ExpandoObject), expando.ReturnType);
            }
        }
        public async Task CancellationTokenPassesThrough()
        {
            using (var source = new CancellationTokenSource())
            {
                dynamic proxy   = new TestProxy("http://example.com");
                dynamic expando = await proxy.get(source.Token, name : "value");

                Assert.AreEqual(source.Token, expando.CancelToken);
            }
        }
        public async Task NoArgsPassedCorrectly()
        {
            dynamic proxy   = new TestProxy("http://example.com");
            dynamic expando = await proxy.get();

            IEnumerable <object>         unnamedArgs = expando.UnnamedArgs;
            IDictionary <string, object> namedArgs   = expando.NamedArgs;

            Assert.AreEqual(0, unnamedArgs.Count());
            Assert.AreEqual(0, namedArgs.Count);
        }
        public async Task UnnamedArgsArePassedCorrectly()
        {
            dynamic proxy   = new TestProxy("http://example.com");
            dynamic expando = await proxy.get("object");

            Assert.AreEqual(0, ((IDictionary <string, object>)expando.NamedArgs).Count);

            IEnumerable <object> unnamedArgs = expando.UnnamedArgs;

            Assert.AreEqual("object", unnamedArgs.First().ToString());
        }
        public async Task NamedArgsArePassedCorrectly()
        {
            dynamic proxy   = new TestProxy("http://example.com");
            dynamic expando = await proxy.get(name : "value");

            Assert.IsFalse(((IEnumerable <object>)expando.UnnamedArgs).Any());

            IDictionary <string, object> namedArgs = expando.NamedArgs;

            Assert.IsTrue(namedArgs.ContainsKey("name"));
            Assert.AreEqual("value", namedArgs["name"]);
        }
        public async Task NamedAndUnnamedArgsArePassedCorrectly()
        {
            dynamic proxy   = new TestProxy("http://example.com");
            dynamic expando = await proxy.get("object", name : "value");

            IEnumerable <object>         unnamedArgs = expando.UnnamedArgs;
            IDictionary <string, object> namedArgs   = expando.NamedArgs;

            Assert.AreEqual(1, unnamedArgs.Count());
            Assert.AreEqual(1, namedArgs.Count);

            Assert.AreEqual("object", unnamedArgs.First().ToString());

            Assert.IsTrue(namedArgs.ContainsKey("name"));
            Assert.AreEqual("value", namedArgs["name"]);
        }