public static ReadResource ( string resourcePath ) : string | ||
resourcePath | string | |
return | string |
public async Task ScopeAsync_Succeeds_When_Name_Is_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 = new MemcachedBucket("default", new ClusterOptions(), new ConfigContext(new ClusterOptions()), mockHttpClusterMap.Object); await bucket.Bootstrap(mockClusterNode.Object).ConfigureAwait(false); var scope = await bucket.ScopeAsync(BucketBase.DefaultScope).ConfigureAwait(false); Assert.Equal(BucketBase.DefaultScope, scope.Name); }
public async Task ScopeAsync_Succeeds_When_Name_Is_Default() { var localhost = HostEndpoint.Parse("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(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8091)); mockClusterNode.Setup(x => x.BootstrapEndpoint).Returns(localhost); mockClusterNode.Setup(x => x.SelectBucketAsync(It.IsAny <IBucket>(), 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); var scope = bucket.Scope(Scope.DefaultScopeName); Assert.Equal(Scope.DefaultScopeName, scope.Name); }
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")); }
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")); }