public void Exists_For_Xattr_Sets_Correct_Flag() { const SubdocPathFlags pathFlags = SubdocPathFlags.Xattr; const SubdocDocFlags docFlags = SubdocDocFlags.InsertDocument; var mockResult = new Mock <IDocumentFragment <dynamic> >(); var mockedInvoker = new Mock <ISubdocInvoker>(); mockedInvoker.Setup(x => x.Invoke(It.IsAny <LookupInBuilder <dynamic> >())) .Returns(mockResult.Object); var lookupBuilder = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var result = lookupBuilder.Exists("path", pathFlags, docFlags) .Execute(); Assert.AreSame(mockResult.Object, result); mockedInvoker.Verify( invoker => invoker.Invoke(It.Is <LookupInBuilder <dynamic> >( builder => builder.FirstSpec().OpCode == OperationCode.SubExist && builder.FirstSpec().Path == "path" && builder.FirstSpec().PathFlags == pathFlags && builder.FirstSpec().DocFlags == docFlags) ), Times.Once ); }
private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs, LookupInOptions options, IInternalSpan span) { //sanity check for deferred bootstrapping errors _bucket.ThrowIfBootStrapFailed(); // convert new style specs into old style builder var builder = new LookupInBuilder <byte[]>(null, null, id, specs); //add the virtual xttar attribute to get the doc expiration time if (options.ExpiryValue) { builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr); } var lookup = new MultiLookup <byte[]> { Key = id, Builder = builder, Cid = Cid, CName = Name, DocFlags = options.AccessDeletedValue ? SubdocDocFlags.AccessDeleted : SubdocDocFlags.None, Span = span }; _operationConfigurator.Configure(lookup, options); await RetryUntilTimeoutOrSuccessAsync(options.TokenValue, options.TimeoutValue, lookup).ConfigureAwait(false); return(lookup); }
private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs, LookupInOptions options) { //sanity check for deferred bootstrapping errors _bucket.ThrowIfBootStrapFailed(); // convert new style specs into old style builder var builder = new LookupInBuilder <byte[]>(null, null, id, specs); //add the virtual xttar attribute to get the doc expiration time if (options.ExpiryValue) { builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr); } var lookup = new MultiLookup <byte[]> { Key = id, Builder = builder, Cid = Cid, CName = Name, Transcoder = _transcoder }; await _bucket.RetryAsync(lookup, options.TokenValue, options.TimeoutValue).ConfigureAwait(false); return(lookup); }
public void GetCommands_Enumerates_ExactlyThreeLookups() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new LookupInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var count = ((LookupInBuilder<dynamic>) builder.Get("boo.foo").Exists("foo.boo").Get("boo.foo")).Count(); Assert.AreEqual(3, count); }
public void GetCommands_Enumerates_ExactlyThreeLookups() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var count = ((LookupInBuilder <dynamic>)builder.Get("boo.foo").Exists("foo.boo").Get("boo.foo")).GetEnumerator().Count(); Assert.AreEqual(3, count); }
public void Test() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new LookupInBuilder<MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var op = new MultiLookup<MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"), new DefaultTranscoder(new DefaultConverter()), 10); builder.Get("foo.bar"); var bytes = op.Write(); }
public void Test() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new LookupInBuilder <MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var op = new MultiLookup <MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"), new DefaultTranscoder(new DefaultConverter()), 10); builder.Get("foo.bar"); var bytes = op.Write(); }
public void MultiLookup_WillRetry_IfCasIsZero() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Get("pathone"); builder.Get("pathtwo"); var op = new MultiLookup <dynamic>("thekey", builder, new Mock <IVBucket>().Object, new Mock <ITypeTranscoder>().Object, 10) { Cas = 0 }; Assert.IsTrue(op.CanRetry()); }
private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <OperationSpec> specs, LookupInOptions options) { // convert new style specs into old style builder var builder = new LookupInBuilder <byte[]>(null, null, id, specs); var lookup = new MultiLookup <byte[]> { Key = id, Builder = builder, Cid = Cid }; await ExecuteOp(lookup, options.Token, options.Timeout); return(lookup); }
public void MultiLookup_Clone() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Get("pathone"); builder.Get("pathtwo"); var op = new MultiLookup <dynamic>("thekey", builder, new Mock <IVBucket>().Object, new Mock <ITypeTranscoder>().Object, 10) { Cas = 100 }; var cloned = (MultiLookup <dynamic>)op.Clone(); Assert.AreEqual(op, cloned); }
public void When_Success_Return_Fragment() { var response = new byte[] { 129, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 83, 67, 82, 65, 77, 45, 83, 72, 65, 53, 49, 50, 32, 83, 67, 82, 65, 77, 45, 83, 72, 65, 50, 53, 54, 32, 83, 67, 82, 65, 77, 45, 83, 72, 65, 49, 32, 67, 82, 65, 77, 45, 77, 68, 53, 32, 80, 76, 65, 73, 78 }; var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new LookupInBuilder<MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var op = new MultiLookup<MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"), new DefaultTranscoder(new DefaultConverter()), 10); op.Data.Write(response, 0, response.Length); var result = op.GetResultWithValue(); }
public void When_Success_Return_Fragment() { var response = new byte[] { 129, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 83, 67, 82, 65, 77, 45, 83, 72, 65, 53, 49, 50, 32, 83, 67, 82, 65, 77, 45, 83, 72, 65, 50, 53, 54, 32, 83, 67, 82, 65, 77, 45, 83, 72, 65, 49, 32, 67, 82, 65, 77, 45, 77, 68, 53, 32, 80, 76, 65, 73, 78 }; var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new LookupInBuilder <MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var op = new MultiLookup <MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"), new DefaultTranscoder(new DefaultConverter()), 10); op.Data.Write(response, 0, response.Length); var result = op.GetResultWithValue(); }
public void GetCount_Sends_Correct_OperationCode_And_Path() { var mockResult = new Mock <IDocumentFragment <dynamic> >(); var mockedInvoker = new Mock <ISubdocInvoker>(); mockedInvoker.Setup(x => x.Invoke(It.IsAny <LookupInBuilder <dynamic> >())).Returns(mockResult.Object); var lookupBuilder = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var result = lookupBuilder.GetCount("path") .Execute(); Assert.AreSame(mockResult.Object, result); mockedInvoker.Verify( invoker => invoker.Invoke(It.Is <LookupInBuilder <dynamic> >( builder => builder.FirstSpec().OpCode == OperationCode.SubGetCount && builder.FirstSpec().Path == "path") ), Times.Once ); }
private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <OperationSpec> specs, LookupInOptions options) { // convert new style specs into old style builder var builder = new LookupInBuilder <byte[]>(null, null, id, specs); //add the virtual xttar attribute to get the doc expiration time if (options.Expiry) { builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr); } var lookup = new MultiLookup <byte[]> { Key = id, Builder = builder, Cid = Cid, Transcoder = _transcoder }; await _bucket.RetryAsync(lookup, options.Token, options.Timeout); return(lookup); }
public void Get_For_Xattr_Sets_Correct_Flag(SubdocLookupFlags flags, byte expected) { var mockResult = new Mock <IDocumentFragment <dynamic> >(); var mockedInvoker = new Mock <ISubdocInvoker>(); mockedInvoker.Setup(x => x.Invoke(It.IsAny <LookupInBuilder <dynamic> >())) .Returns(mockResult.Object); var lookupBuilder = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var result = lookupBuilder.Get("path", flags) .Execute(); Assert.AreSame(mockResult.Object, result); mockedInvoker.Verify( invoker => invoker.Invoke(It.Is <LookupInBuilder <dynamic> >( builder => builder.FirstSpec().OpCode == OperationCode.SubGet && builder.FirstSpec().Path == "path" && builder.FirstSpec().Flags == expected) ), Times.Once ); }
public MultiLookup(string key, LookupInBuilder <T> builder, IVBucket vBucket, ITypeTranscoder transcoder, uint timeout) : base(key, vBucket, transcoder, timeout) { _builder = builder; }
public void MultiLookup_WillRetry_IfCasIsZero() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new LookupInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Get("pathone"); builder.Get("pathtwo"); var op = new MultiLookup<dynamic>("thekey", builder, new Mock<IVBucket>().Object, new Mock<ITypeTranscoder>().Object, 10) { Cas = 0 }; Assert.IsTrue(op.CanRetry()); }
public void MultiLookup_Clone() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new LookupInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Get("pathone"); builder.Get("pathtwo"); var op = new MultiLookup<dynamic>("thekey", builder, new Mock<IVBucket>().Object, new Mock<ITypeTranscoder>().Object, 10) { Cas = 100 }; var cloned = (MultiLookup<dynamic>)op.Clone(); Assert.AreEqual(op, cloned); }
public SubGet(LookupInBuilder <T> builder, string key, IVBucket vBucket, ITypeTranscoder transcoder, uint timeout) : base(builder, key, vBucket, transcoder, timeout) { CurrentSpec = builder.FirstSpec(); Path = CurrentSpec.Path; }
public FakeMultiLookupOperation(string key, LookupInBuilder <T> builder, IVBucket vBucket, ITypeTranscoder transcoder, uint timeout) : base(key, builder, vBucket, transcoder, timeout) { }