コード例 #1
0
        public void When_Configuration_Has_Password_For_Bucket_It_Is_Used()
        {
            //first check that without password default one is used (which should work)
            var config = TestConfiguration.GetCurrentConfiguration();

            ClusterHelper.Initialize(config);
            var bucket = ClusterHelper.GetBucket("beer-sample");

            Assert.NotNull(bucket);

            //then check that putting a password in configuration fails the same test
            ClusterHelper.RemoveBucket("beer-sample");
            config.BucketConfigs["beer-sample"] = new BucketConfiguration()
            {
                BucketName = "beer-sample",
                Password   = "******"
            };
            ClusterHelper.Initialize(config);

            try
            {
                bucket = ClusterHelper.GetBucket("beer-sample");
                Assert.Fail("Unexpected GetBucket success");
            }
            catch (AggregateException e)
            {
                var exceptions = e.Flatten();
                Assert.IsTrue(exceptions.InnerExceptions.OfType <AuthenticationException>().Any(), "Expected authentication exception");
            }
        }
コード例 #2
0
        public void When_RemoveBucket_Is_Called_Bucket_Count_Is_Zero()
        {
            ClusterHelper.Initialize();

            //open a bucket and get the reference
            var bucket1 = ClusterHelper.GetBucket("default");
            var bucket2 = ClusterHelper.GetBucket("default");

            Assert.AreEqual(1, ClusterHelper.Count());
            ClusterHelper.RemoveBucket("default");
            Assert.AreEqual(0, ClusterHelper.Count());
        }
コード例 #3
0
        public void When_RemoveBucket_Is_Called_Bucket_Count_Is_Zero()
        {
            ClusterHelper.Initialize(TestConfiguration.GetCurrentConfiguration());
            ClusterHelper.Get().SetupEnhancedAuth();

            //open a bucket and get the reference
            var bucket1 = ClusterHelper.GetBucket("default");
            var bucket2 = ClusterHelper.GetBucket("default");

            Assert.AreEqual(1, ClusterHelper.Count());
            ClusterHelper.RemoveBucket("default");
            Assert.AreEqual(0, ClusterHelper.Count());
        }
コード例 #4
0
        public void When_Bucket_Is_Opened_On_Two_Seperate_Threads_And_RemoveBucket_Is_Called_Count_Is_Zero()
        {
            ClusterHelper.Initialize();
            var t1 = new Thread(OpenBucket);
            var t2 = new Thread(OpenBucket);

            t1.Start();
            t2.Start();

            TwoThreadsCompleted.Wait();
            Assert.AreEqual(1, ClusterHelper.Count());
            ClusterHelper.RemoveBucket("default");
            Assert.AreEqual(0, ClusterHelper.Count());
        }
コード例 #5
0
        public void When_Bucket_Is_Opened_On_Two_Seperate_Threads_And_RemoveBucket_Is_Called_Count_Is_Zero()
        {
            ClusterHelper.Initialize(TestConfiguration.GetCurrentConfiguration());
            ClusterHelper.Get().SetupEnhancedAuth();

            var t1 = new Thread(OpenBucket);
            var t2 = new Thread(OpenBucket);

            t1.Start();
            t2.Start();

            TwoThreadsCompleted.Wait();
            Assert.AreEqual(1, ClusterHelper.Count());
            ClusterHelper.RemoveBucket("default");
            Assert.AreEqual(0, ClusterHelper.Count());
        }
コード例 #6
0
        public void When_Configuration_Has_Password_For_Bucket_It_Is_Used()
        {
            //first check that without password default one is used (which should work)
            var config = new ClientConfiguration
            {
                Servers = new List <Uri>
                {
                    new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
                }
            };

            ClusterHelper.Initialize(config);
            var bucket = ClusterHelper.GetBucket("beer-sample");

            Assert.NotNull(bucket);

            //then check that putting a password in configuration fails the same test
            ClusterHelper.RemoveBucket("beer-sample");
            config.BucketConfigs["beer-sample"] = new BucketConfiguration()
            {
                BucketName = "beer-sample",
                Password   = "******"
            };
            ClusterHelper.Initialize(config);

            try
            {
                bucket = ClusterHelper.GetBucket("beer-sample");
                Assert.Fail("Unexpected GetBucket success");
            }
            catch (AggregateException e)
            {
                e = e.Flatten();
                if (!(e.InnerException is AuthenticationException))
                {
                    Assert.Fail("Expected authentication exception, got " + e.InnerException);
                }
                //success
            }
        }