Esempio n. 1
0
        public async Task ScopeAsync_Throws_NotSupportedException_When_Name_Is_Not_Default()
        {
            var localhost    = HostEndpoint.Parse("10.112.192.102:8091");
            var bucketConfig = ResourceHelper.ReadResource("mycache.json", InternalSerializationContext.Default.BucketConfig);

            bucketConfig.Nodes.RemoveAt(1);

            var mockClusterNode = new Mock <IClusterNode>();

            mockClusterNode.Setup(x => x.EndPoint).Returns(new HostEndpointWithPort("127.0.0.1", 8091));
            mockClusterNode.Setup(x => x.SelectBucketAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.CompletedTask);

            var mockHttpClusterMap = new Mock <HttpClusterMapBase>();

            mockHttpClusterMap.Setup(x =>
                                     x.GetClusterMapAsync("default", localhost, CancellationToken.None)).
            Returns(Task.FromResult(bucketConfig));

            var bucket = CreateMemcachedBucket();
            await bucket.BootstrapAsync(mockClusterNode.Object).ConfigureAwait(false);

            Assert.Throws <NotSupportedException>(() => bucket.Scope("xxxx"));
        }
Esempio n. 2
0
        public async Task ScopeAsync_Throws_NotSupportedException_When_Name_Is_Not_Default()
        {
            var localhost    = new Uri("http://10.112.192.102:8091");
            var bucketConfig = ResourceHelper.ReadResource <BucketConfig>("mycache.json");

            bucketConfig.Nodes.RemoveAt(1);

            var mockClusterNode = new Mock <IClusterNode>();

            mockClusterNode.Setup(x => x.EndPoint).Returns(localhost.GetIpEndPoint(8091, false));
            mockClusterNode.Setup(x => x.BootstrapUri).Returns(localhost);
            mockClusterNode.Setup(x => x.SelectBucket("default")).Returns(Task.CompletedTask);

            var mockHttpClusterMap = new Mock <HttpClusterMapBase>();

            mockHttpClusterMap.Setup(x =>
                                     x.GetClusterMapAsync("default", localhost, CancellationToken.None)).
            Returns(Task.FromResult(bucketConfig));

            var bucket = CreateMemcachedBucket();
            await bucket.BootstrapAsync(mockClusterNode.Object).ConfigureAwait(false);

            Assert.Throws <NotSupportedException>(() => bucket.Scope("xxxx"));
        }