public void SelectsConstructorBaseOnConfiguration() { IConfiguration configuration = GetConfiguration(new KeyValuePair <string, string>("connectionstring", "CS")); var factory = new ConfigurationClientFactory(); var clientOptions = new TestClientOptions(); var client = (TestClient)factory.CreateClient(typeof(TestClient), typeof(TestClientOptions), clientOptions, configuration); Assert.AreEqual("CS", client.ConnectionString); Assert.AreSame(clientOptions, client.Options); }
public void ConvertsUriConstructorParameters() { IConfiguration configuration = GetConfiguration(new KeyValuePair <string, string>("uri", "http://localhost")); var factory = new ConfigurationClientFactory(); var clientOptions = new TestClientOptions(); var client = (TestClient)factory.CreateClient(typeof(TestClient), typeof(TestClientOptions), clientOptions, configuration); Assert.AreEqual("http://localhost/", client.Uri.ToString()); Assert.AreSame(clientOptions, client.Options); }
public void ThrowsExceptionWithInformationAboutArguments() { IConfiguration configuration = GetConfiguration(); var clientOptions = new TestClientOptions(); var exception = Assert.Throws <InvalidOperationException>(() => ConfigurationClientFactory.CreateClient(typeof(TestClient), typeof(TestClientOptions), clientOptions, configuration)); Assert.AreEqual("Unable to find matching constructor. Define one of the follow sets of configuration parameters:" + Environment.NewLine + "1. connectionString" + Environment.NewLine + "2. uri" + Environment.NewLine, exception.Message); }