public RequiredServiceElementBuilder( ILoggerFactory loggerFactory, EmptyService service) { LoggerFactory = loggerFactory; Service = service; }
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 ReleaseInstance_HttpInstanceProvider_Null_Instance_Throws() { EmptyService instance = new EmptyService(); InstanceContext context = new InstanceContext(instance); HttpInstanceProvider provider = new SHttpInstanceProvider(); ExceptionAssert.ThrowsArgumentNull("instance", () => provider.ReleaseInstance(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 RequiredServiceElementBuilder( ILoggerFactory loggerFactory, EmptyService service, IDataUpdateService updateService) { LoggerFactory = loggerFactory; Service = service; UpdateService = updateService; }
public RequiredServiceElement( ILoggerFactory loggerFactory, EmptyService service, IDataUpdateService updateService) : base(loggerFactory.CreateLogger <RequiredServiceElement>()) { LoggerFactory = loggerFactory; Service = service; UpdateService = updateService; }
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_Allows_Null_Instance() { EmptyService instance = new EmptyService(); InstanceContext context = new InstanceContext(instance); Message message = new HttpRequestMessage().ToMessage(); SHttpInstanceProvider provider = new SHttpInstanceProvider(); provider.OnGetInstanceInstanceContextHttpRequestMessage = (ctx, msg) => { return null; }; object returnedInstance = ((IInstanceProvider)provider).GetInstance(context, message); Assert.IsNull(returnedInstance, "Instance provider should have returned a null instance"); }
public void CreateInstance_Returns_Custom_Instance() { EmptyService instance = new EmptyService(); InstanceContext context = new InstanceContext(instance); Message message = new HttpRequestMessage().ToMessage(); SHttpInstanceProvider provider = new SHttpInstanceProvider(); provider.OnGetInstanceInstanceContextHttpRequestMessage = (ctx, msg) => instance; object returnedInstance = ((IInstanceProvider)provider).GetInstance(context, message); Assert.AreEqual(instance, returnedInstance, "Instance provider should have returned the same instance we provided to the mock"); }
public void CreateInstance_Allows_Null_Instance() { EmptyService instance = new EmptyService(); InstanceContext context = new InstanceContext(instance); Message message = new HttpRequestMessage().ToMessage(); SHttpInstanceProvider provider = new SHttpInstanceProvider(); provider.OnGetInstanceInstanceContextHttpRequestMessage = (ctx, msg) => { return(null); }; object returnedInstance = ((IInstanceProvider)provider).GetInstance(context, message); Assert.IsNull(returnedInstance, "Instance provider should have returned a null instance"); }
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 ReleaseInstance_Calls_OnReleaseInstance() { EmptyService instance = new EmptyService(); InstanceContext context = new InstanceContext(instance); InstanceContext seenContext = null; object seenInstance = null; SHttpInstanceProvider provider = new SHttpInstanceProvider(); provider.OnReleaseInstanceInstanceContextObject = (ic, i) => { seenContext = ic; seenInstance = i; }; provider.ReleaseInstance(context, instance); Assert.AreSame(context, seenContext, "Did not receive context in OnCreateInstance"); Assert.AreSame(instance, seenInstance, "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_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"); }