public TestTargetRegistry Add(string environment, string application, Uri baseAddress, Action <TestDependencyRegistry> testDependencies = null) { if (environment == null) { throw new ArgumentNullException("environment"); } if (application == null) { throw new ArgumentNullException("application"); } if (baseAddress == null) { throw new ArgumentNullException("baseAddress"); } if (!baseAddress.IsAbsoluteUri) { throw new ArgumentException("Base address must be an absolute URI."); } var testTarget = new TestTarget { Application = application, Environment = environment, BaseAddress = baseAddress }; var container = new PocketContainer() .Register(c => new HttpClient()) .Register(c => testTarget); if (testDependencies != null) { testDependencies(new TestDependencyRegistry((t, func) => container.Register(t, c => func()))); } container.AfterResolve <HttpClient>((c, client) => { if (client.BaseAddress == null) { client.BaseAddress = testTarget.BaseAddress; } return(client); }); testTarget.ResolveDependency = container.Resolve; targets.Add(environment + ":" + application, testTarget); return(this); }