Exemplo n.º 1
0
        public void CanCreateClientWithInfiniteWaitTime()
        {
            var config = BasicConfig().Build();

            using (var client = LdClient.Init(config, BasicUser, System.Threading.Timeout.InfiniteTimeSpan)) { }
            TestUtil.ClearClient();
        }
Exemplo n.º 2
0
 // 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;
     }));
 }
Exemplo n.º 3
0
 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)) { }
     });
 }
Exemplo n.º 4
0
 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();
     });
 }
Exemplo n.º 5
0
        public void CannotCreateClientWithNegativeWaitTime()
        {
            var config = BasicConfig().Build();

            Assert.Throws <ArgumentOutOfRangeException>(() => LdClient.Init(config, BasicUser, TimeSpan.FromMilliseconds(-2)));
        }
Exemplo n.º 6
0
        public void CannotCreateClientWithNullUser()
        {
            var config = BasicConfig().Build();

            Assert.Throws <ArgumentNullException>(() => LdClient.Init(config, null, TimeSpan.Zero));
        }
Exemplo n.º 7
0
 public void CannotCreateClientWithNullConfig()
 {
     Assert.Throws <ArgumentNullException>(() => LdClient.Init((Configuration)null, BasicUser, TimeSpan.Zero));
 }
Exemplo n.º 8
0
 private LdClient MakeClient(User u) =>
 LdClient.Init(BasicConfig().DataSource(_testData).Events(_factory).Build(),
               u, TimeSpan.FromSeconds(1));