• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BucketContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BucketContext的典型用法代码示例。如果您正苦于以下问题:C# BucketContext类的具体用法?C# BucketContext怎么用?C# BucketContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BucketContext类属于命名空间,在下文中一共展示了BucketContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateQueryRequest_Any_ReturnsQueryWrappedInQueryRequest

        public void CreateQueryRequest_Any_ReturnsQueryWrappedInQueryRequest()
        {
            // Arrange

            var bucket = new Mock<IBucket>();
            bucket.Setup(m => m.Name).Returns("default");
            bucket.Setup(m => m.Configuration).Returns(new BucketConfiguration()
            {
                PoolConfiguration = new PoolConfiguration(new ClientConfiguration())
            });

            var context = new BucketContext(bucket.Object);
            var query = context.Query<Brewery>();

            // Act

            var result = LinqQueryRequest.CreateQueryRequest(query, p => p.Any(q => q.Name == "name"));

            // Assert

            const string queryStr = "SELECT true as result FROM `default` as `Extent1` WHERE (`Extent1`.`name` = 'name') LIMIT 1";

            Assert.NotNull(result);
            Assert.AreEqual(queryStr, result.GetOriginalStatement());
            Assert.True(result.ScalarResultBehavior.ResultExtractionRequired);
            Assert.AreEqual(false, result.ScalarResultBehavior.NoRowsResult);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:27,代码来源:LinqQueryRequestTests.cs


示例2: BeginChangeTracking_DoesNotClear_Modified_List

        public void BeginChangeTracking_DoesNotClear_Modified_List()
        {
            var db = new BucketContext(ClusterHelper.GetBucket("beer-sample"));

            db.BeginChangeTracking();

            var query = from x in db.Query<Beer>()
                        where x.Type == "beer"
                        select x;

            db.BeginChangeTracking();

            var context = db as IChangeTrackableContext;

            Assert.AreEqual(0, context.ModifiedCount);

            var brewery = query.First();
            brewery.Abv = 10;

            Assert.AreEqual(1, context.ModifiedCount);

            db.BeginChangeTracking();

            Assert.AreEqual(1, context.ModifiedCount);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:25,代码来源:BucketContextTests.cs


示例3: GetDocumentId_When_Id_Field_DoesNotExist_Throw_KeyAttributeMissingException

 public void GetDocumentId_When_Id_Field_DoesNotExist_Throw_KeyAttributeMissingException()
 {
     var route = new Route();
     var bucket = new Mock<IBucket>();
     var ctx = new BucketContext(bucket.Object);
     Assert.Throws<KeyAttributeMissingException>(()=>ctx.GetDocumentId(route));
 }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:7,代码来源:BucketContextTests.cs


示例4: GetDocumentId_When_DocId_Exists_Use_It

 public void GetDocumentId_When_DocId_Exists_Use_It()
 {
     var beer = new Beer {Name = "beer1"};
     var bucket = new Mock<IBucket>();
     var ctx = new BucketContext(bucket.Object);
     var id = ctx.GetDocumentId(beer);
     Assert.AreEqual("beer1", id);
 }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:8,代码来源:BucketContextTests.cs


示例5: Save_When_KeyAttribute_Is_Not_Defined_Throw_DocumentIdMissingException

 public void Save_When_KeyAttribute_Is_Not_Defined_Throw_DocumentIdMissingException()
 {
     var brewery = new Brewery();
        var bucket = new Mock<IBucket>();
        var result = new Mock<IOperationResult<Brewery>>();
        result.Setup(x => x.Status).Returns(ResponseStatus.Success);
        bucket.Setup(x => x.Upsert(It.IsAny<string>(), It.IsAny<Brewery>())).Returns(result.Object);
        var ctx = new BucketContext(bucket.Object);
        Assert.Throws<KeyAttributeMissingException>(()=>ctx.Save(brewery));
 }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:10,代码来源:BucketContextTests.cs


示例6: Remove_When_Write_Is_Not_Succesful_Throw_CouchbaseWriteException

 public void Remove_When_Write_Is_Not_Succesful_Throw_CouchbaseWriteException()
 {
     var beer = new Beer();
        var bucket = new Mock<IBucket>();
        var result = new Mock<IOperationResult<Beer>>();
        result.Setup(x => x.Success).Returns(false);
        bucket.Setup(x => x.Remove(It.IsAny<string>())).Returns(result.Object);
        var ctx = new BucketContext(bucket.Object);
        Assert.Throws<CouchbaseWriteException>(() => ctx.Remove(beer));
 }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:10,代码来源:BucketContextTests.cs


示例7: InitTest

        internal virtual void InitTest(Settings settings)
        {
            s3 = new S3Service()
            {
                AccessKeyID = settings.AccessKeyID,
                SecretAccessKey = settings.SecretAccessKey
            };

            bucket = new BucketContext() { BucketName = settings.TestBucketName, Service = s3 };
        }
开发者ID:rdkhatch,项目名称:LitS3,代码行数:10,代码来源:S3TestBase.cs


示例8: Remove_When_Write_Is_Succesful_Return_Success

 public void Remove_When_Write_Is_Succesful_Return_Success()
 {
     var beer = new Beer();
        var bucket = new Mock<IBucket>();
        var result = new Mock<IOperationResult<Beer>>();
        result.Setup(x => x.Status).Returns(ResponseStatus.Success);
        result.Setup(x => x.Success).Returns(true);
        bucket.Setup(x => x.Remove(It.IsAny<string>())).Returns(result.Object);
        var ctx = new BucketContext(bucket.Object);
        ctx.Remove(beer);
 }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:11,代码来源:BucketContextTests.cs


示例9: ExecuteAsync_WithAvg_ReturnsAvg

        public async Task ExecuteAsync_WithAvg_ReturnsAvg()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var beers = from b in context.Query<Beer>()
                        select b;

            var result = await beers.ExecuteAsync(p => p.Average(q => q.Abv));
            Console.WriteLine(result);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:11,代码来源:QueryExtensionTests.cs


示例10: Test_Basic_Query

        public void Test_Basic_Query()
        {
            var db = new BucketContext(ClusterHelper.GetBucket("beer-sample"));
            var query = from x in db.Query<Beer>()
                where x.Type == "beer"
                select x;

            foreach (var beer in query)
            {
                Console.WriteLine(beer.Name);
            }
        }
开发者ID:baoduy,项目名称:Linq2Couchbase,代码行数:12,代码来源:BucketContextTests.cs


示例11: ExecuteAsync_Any_ReturnsTrue

        public async Task ExecuteAsync_Any_ReturnsTrue()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var beers = from b in context.Query<Beer>()
                        where b.Type == "beer" && b.Name == "21A IPA"
                        select b;

            var result = await beers.ExecuteAsync(p => p.Any());

            Assert.True(result);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:13,代码来源:QueryExtensionTests.cs


示例12: ExecuteAsync_FirstOrDefaultNoValues_ReturnsDefault

        public async Task ExecuteAsync_FirstOrDefaultNoValues_ReturnsDefault()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var beers = from b in context.Query<Beer>()
                        where b.Name == "abcdefg"
                        select b.Abv;

            var result = await beers.ExecuteAsync(p => p.FirstOrDefault());

            Assert.AreEqual(0M, result);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:13,代码来源:QueryExtensionTests.cs


示例13: ExecuteAsync_First_ReturnsFirst

        public async Task ExecuteAsync_First_ReturnsFirst()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var beers = from b in context.Query<Beer>()
                        select b;

            var result = await beers.ExecuteAsync(p => p.First());

            Assert.NotNull(result);
            Console.WriteLine(result.Name);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:13,代码来源:QueryExtensionTests.cs


示例14: ExecuteAsync_NoParameters_ReturnsList

        public async Task ExecuteAsync_NoParameters_ReturnsList()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var beers = from b in context.Query<Beer>()
                select b;

            var results = (await beers.Take(1).ExecuteAsync()).ToList();
            Assert.AreEqual(1, results.Count);

            foreach (var beer in results)
            {
                Console.WriteLine(beer.Name);
            }
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:16,代码来源:QueryExtensionTests.cs


示例15: Query_DisableProxyGeneration_ReturnsNoProxy

        public void Query_DisableProxyGeneration_ReturnsNoProxy()
        {
            var db = new BucketContext(ClusterHelper.GetBucket("beer-sample"));

            const string documentId = "21st_amendment_brewery_cafe-21a_ipa";

            var query = from x in db.Query<Beer>().UseKeys(new[] { documentId })
                        where x.Type == "beer"
                        select x;

            var beer = query.First();

            // ReSharper disable once SuspiciousTypeConversion.Global
            var status = beer as ITrackedDocumentNode;

            Assert.Null(status);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:17,代码来源:BucketContextTests.cs


示例16: AddToMutationState_DefaultToken_DoesNothing

        public void AddToMutationState_DefaultToken_DoesNothing()
        {
            // Arrange

            var bucket = new Mock<IBucket>();
            bucket.SetupGet(m => m.Name).Returns("default");

            var db = new BucketContext(bucket.Object);

            // Act

            db.AddToMutationState(new MutationToken("default", -1, -1, 1));

            // Assert

            Assert.IsNull(db.MutationState);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:17,代码来源:BucketContextTests.cs


示例17: Main

        static void Main(string[] args)
        {
            var config = new ClientConfiguration
            {
                Servers = new List<Uri> { new Uri("http://localhost:8091") }
            };

            ClusterHelper.Initialize(config);
            var db = new BucketContext(ClusterHelper.GetBucket("beer-sample"));
            var query = from b in db.Query<Beer>()
                        select b;

            foreach (var beer in query)
            {
                Console.WriteLine(beer.Type + ": " + beer.Name);
            }
            Console.Read();
            ClusterHelper.Close();
        }
开发者ID:vinaas,项目名称:couchbase-net-examples,代码行数:19,代码来源:Program.cs


示例18: AggregateTests_GroupBy

        public void AggregateTests_GroupBy()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var breweries =
                from beer in context.Query<Beer>()
                where beer.Type == "beer"
                group beer by beer.BreweryId
                into g
                orderby g.Key
                select new {breweryid = g.Key, count = g.Count(), avgAbv = g.Average(p => p.Abv)};

            var results = breweries.Take(1).ToList();
            Assert.AreEqual(1, results.Count);

            foreach (var brewery in results)
            {
                Console.WriteLine("Brewery {0} has {1} beers with {2:f2} average ABV", brewery.breweryid, brewery.count,
                    brewery.avgAbv);
            }
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:22,代码来源:QueryTests.cs


示例19: AggregateTests_JoinBeforeGroupByAndMultipartKey

        public void AggregateTests_JoinBeforeGroupByAndMultipartKey()
        {
            var bucket = ClusterHelper.GetBucket("beer-sample");
            var context = new BucketContext(bucket);

            var breweries =
                from beer in context.Query<Beer>()
                join brewery in context.Query<Brewery>() on beer.BreweryId equals N1QlFunctions.Key(brewery)
                where beer.Type == "beer"
                group beer by new {breweryid = beer.BreweryId, breweryName = brewery.Name}
                into g
                select new {g.Key.breweryName, count = g.Count(), avgAbv = g.Average(p => p.Abv)};

            var results = breweries.Take(1).ToList();
            Assert.AreEqual(1, results.Count);

            foreach (var brewery in results)
            {
                Console.WriteLine("Brewery {0} has {1} beers with {2:f2} average ABV", brewery.breweryName,
                    brewery.count, brewery.avgAbv);
            }
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:22,代码来源:QueryTests.cs


示例20: Query_EnableProxyGenerationAddAddress_FlagAsDirty

        public void Query_EnableProxyGenerationAddAddress_FlagAsDirty()
        {
            var db = new BucketContext(ClusterHelper.GetBucket("beer-sample"))
            {
                EnableChangeTracking = true
            };

            var query = from x in db.Query<Brewery>()
                        where x.Type == "brewery" && x.Address.Any()
                        select x;

            var brewery = query.First();
            var addresses = brewery.Address;

            addresses.Add("Test");

            // ReSharper disable once SuspiciousTypeConversion.Global
            var status = addresses as ITrackedDocumentNode;

            Assert.NotNull(status);
            Assert.IsTrue(status.IsDirty);
        }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:22,代码来源:BucketContextTests.cs



注:本文中的BucketContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Buff类代码示例发布时间:2022-05-24
下一篇:
C# Bucket类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap