public void CreateInstance_Null_Request_Throws()
        {
            EmptyService         instance = new EmptyService();
            InstanceContext      context  = new InstanceContext(instance);
            HttpInstanceProvider provider = new SHttpInstanceProvider();

            ExceptionAssert.ThrowsArgumentNull("request", () => provider.GetInstance(context, null));
        }
        public void CreateInstance_Null_InstanceContext_Throws()
        {
            EmptyService      instance = new EmptyService();
            InstanceContext   context  = null;
            IInstanceProvider provider = new SHttpInstanceProvider();
            Message           message  = new HttpRequestMessage().ToMessage();

            ExceptionAssert.ThrowsArgumentNull("instanceContext", () => provider.GetInstance(context, message));
        }
        public void CreateInstance_Null_Message_Throws()
        {
            EmptyService      instance = new EmptyService();
            InstanceContext   context  = new InstanceContext(instance);
            IInstanceProvider provider = new SHttpInstanceProvider();
            Message           message  = null;

            ExceptionAssert.ThrowsArgumentNull("message", () => provider.GetInstance(context, message));
        }
        public void CreateInstance_Non_Http_Message_Throws()
        {
            EmptyService      instance = new EmptyService();
            InstanceContext   context  = new InstanceContext(instance);
            IInstanceProvider provider = new SHttpInstanceProvider();
            Message           message  = Message.CreateMessage(MessageVersion.None, "notUsed");

            ExceptionAssert.Throws <InvalidOperationException>(
                SR.HttpInstanceProviderNullRequest(typeof(SHttpInstanceProvider).Name, typeof(HttpRequestMessage).Name, "GetInstance"),
                () => provider.GetInstance(context, message));
        }
        public void CreateInstance_Simple_Calls_OnCreateInstance()
        {
            EmptyService    instance = new EmptyService();
            InstanceContext context  = new InstanceContext(instance);

            InstanceContext       seenContext = null;
            SHttpInstanceProvider provider    = new SHttpInstanceProvider();

            provider.OnGetInstanceInstanceContext =
                (ic) =>
            {
                seenContext = ic;
                return("hello");
            };

            object actualInstance = provider.GetInstance(context);

            Assert.AreSame(context, seenContext, "Did not receive context in OnCreateInstance");
            Assert.AreEqual("hello", actualInstance, "Did not pass back instance created");
        }
        public void CreateInstance_Calls_OnCreateInstance()
        {
            EmptyService instance = new EmptyService();
            InstanceContext context = new InstanceContext(instance);
            HttpRequestMessage requestMessage = new HttpRequestMessage();

            InstanceContext seenContext = null;
            HttpRequestMessage seenMessage = null;
            SHttpInstanceProvider provider = new SHttpInstanceProvider();
            provider.OnGetInstanceInstanceContextHttpRequestMessage =
                (ic, m) =>
                {
                    seenContext = ic;
                    seenMessage = m;
                    return "hello";
                };

            object actualInstance = provider.GetInstance(context, requestMessage);

            Assert.AreSame(context, seenContext, "Did not receive context in OnCreateInstance");
            Assert.AreSame(requestMessage, seenMessage, "Did not get Message");
            Assert.AreEqual("hello", actualInstance, "Did not pass back instance created");
        }
        public void CreateInstance_Calls_OnCreateInstance()
        {
            EmptyService       instance       = new EmptyService();
            InstanceContext    context        = new InstanceContext(instance);
            HttpRequestMessage requestMessage = new HttpRequestMessage();

            InstanceContext       seenContext = null;
            HttpRequestMessage    seenMessage = null;
            SHttpInstanceProvider provider    = new SHttpInstanceProvider();

            provider.OnGetInstanceInstanceContextHttpRequestMessage =
                (ic, m) =>
            {
                seenContext = ic;
                seenMessage = m;
                return("hello");
            };

            object actualInstance = provider.GetInstance(context, requestMessage);

            Assert.AreSame(context, seenContext, "Did not receive context in OnCreateInstance");
            Assert.AreSame(requestMessage, seenMessage, "Did not get Message");
            Assert.AreEqual("hello", actualInstance, "Did not pass back instance created");
        }
        public void CreateInstance_Simple_HttpInstanceProvider_Null_InstanceContext_Throws()
        {
            HttpInstanceProvider provider = new SHttpInstanceProvider();

            ExceptionAssert.ThrowsArgumentNull("instanceContext", () => provider.GetInstance(null));
        }
 public void CreateInstance_Non_Http_Message_Throws()
 {
     EmptyService instance = new EmptyService();
     InstanceContext context = new InstanceContext(instance);
     IInstanceProvider provider = new SHttpInstanceProvider();
     Message message = Message.CreateMessage(MessageVersion.None, "notUsed");
     ExceptionAssert.Throws<InvalidOperationException>(
         SR.HttpInstanceProviderNullRequest(typeof(SHttpInstanceProvider).Name, typeof(HttpRequestMessage).Name, "GetInstance"),
         () =>provider.GetInstance(context, message));
 }
Esempio n. 10
0
 public void CreateInstance_HttpInstanceProvider_Null_InstanceContext_Throws()
 {
     HttpInstanceProvider provider = new SHttpInstanceProvider();
     ExceptionAssert.ThrowsArgumentNull("instanceContext", () => provider.GetInstance(null, new HttpRequestMessage()));
 }
Esempio n. 11
0
        public void CreateInstance_Simple_Calls_OnCreateInstance()
        {
            EmptyService instance = new EmptyService();
            InstanceContext context = new InstanceContext(instance);

            InstanceContext seenContext = null;
            SHttpInstanceProvider provider = new SHttpInstanceProvider();
            provider.OnGetInstanceInstanceContext =
                (ic) =>
                {
                    seenContext = ic;
                    return "hello";
                };

            object actualInstance = provider.GetInstance(context);

            Assert.AreSame(context, seenContext, "Did not receive context in OnCreateInstance");
            Assert.AreEqual("hello", actualInstance, "Did not pass back instance created");
        }
Esempio n. 12
0
 public void CreateInstance_Null_Request_Throws()
 {
     EmptyService instance = new EmptyService();
     InstanceContext context = new InstanceContext(instance);
     HttpInstanceProvider provider = new SHttpInstanceProvider();
     ExceptionAssert.ThrowsArgumentNull("request", () => provider.GetInstance(context, null));
 }
Esempio n. 13
0
 public void CreateInstance_Null_Message_Throws()
 {
     EmptyService instance = new EmptyService();
     InstanceContext context = new InstanceContext(instance);
     IInstanceProvider provider = new SHttpInstanceProvider();
     Message message = null;
     ExceptionAssert.ThrowsArgumentNull("message", () => provider.GetInstance(context, message));
 }
Esempio n. 14
0
 public void CreateInstance_Null_InstanceContext_Throws()
 {
     EmptyService instance = new EmptyService();
     InstanceContext context = null;
     IInstanceProvider provider = new SHttpInstanceProvider();
     Message message = new HttpRequestMessage().ToMessage();
     ExceptionAssert.ThrowsArgumentNull("instanceContext", () => provider.GetInstance(context, message));
 }