public void CanCreateClientWithInfiniteWaitTime() { var config = BasicConfig().Build(); using (var client = LdClient.Init(config, BasicUser, System.Threading.Timeout.InfiniteTimeSpan)) { } TestUtil.ClearClient(); }
// Calls LdClient.Init, but then sets LdClient.Instance to null so other tests can // instantiate their own independent clients. Application code cannot do this because // the LdClient.Instance setter has internal scope. public static LdClient CreateClient(Configuration config, User user, TimeSpan?timeout = null) { return(WithClientLock(() => { ClearClient(); LdClient client = LdClient.Init(config, user, timeout ?? TimeSpan.FromSeconds(1)); client.DetachInstance(); return client; })); }
public void CanCreateNewClientAfterDisposingOfSharedInstance() { TestUtil.WithClientLock(() => { TestUtil.ClearClient(); var config = BasicConfig().Build(); using (var client0 = LdClient.Init(config, BasicUser, TimeSpan.Zero)) { } Assert.Null(LdClient.Instance); // Dispose() is called automatically at end of "using" block using (var client1 = LdClient.Init(config, BasicUser, TimeSpan.Zero)) { } }); }
public void SharedClientIsTheOnlyClientAvailable() { TestUtil.WithClientLock(() => { var config = BasicConfig().Build(); using (var client = LdClient.Init(config, BasicUser, TimeSpan.Zero)) { Assert.Throws <Exception>(() => LdClient.Init(config, BasicUser, TimeSpan.Zero)); } TestUtil.ClearClient(); }); }
public void CannotCreateClientWithNegativeWaitTime() { var config = BasicConfig().Build(); Assert.Throws <ArgumentOutOfRangeException>(() => LdClient.Init(config, BasicUser, TimeSpan.FromMilliseconds(-2))); }
public void CannotCreateClientWithNullUser() { var config = BasicConfig().Build(); Assert.Throws <ArgumentNullException>(() => LdClient.Init(config, null, TimeSpan.Zero)); }
public void CannotCreateClientWithNullConfig() { Assert.Throws <ArgumentNullException>(() => LdClient.Init((Configuration)null, BasicUser, TimeSpan.Zero)); }
private LdClient MakeClient(User u) => LdClient.Init(BasicConfig().DataSource(_testData).Events(_factory).Build(), u, TimeSpan.FromSeconds(1));