public void Remove_ThrowsArgumentException_WhenPathIsEmpty(string path) { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); Assert.Throws<ArgumentException>(() => builder.Remove(path)); }
public void Remove_ThrowsArgumentException_WhenPathIsEmpty(string path) { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove(path); }
public void Remove_For_Xattr_Sets_Correct_Flag(SubdocMutateFlags flags, byte expected) { var mockResult = new Mock <IDocumentFragment <dynamic> >(); var mockedInvoker = new Mock <ISubdocInvoker>(); mockedInvoker.Setup(x => x.Invoke(It.IsAny <MutateInBuilder <dynamic> >())) .Returns(mockResult.Object); var mutateBuilder = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey"); var result = mutateBuilder.Remove("path", flags) .Execute(); Assert.AreSame(mockResult.Object, result); mockedInvoker.Verify( invoker => invoker.Invoke(It.Is <MutateInBuilder <dynamic> >( builder => builder.FirstSpec().OpCode == OperationCode.SubDelete && builder.FirstSpec().Path == "path" && builder.FirstSpec().Flags == expected ) ), Times.Once ); }
public void MultiMutation_WillRetry_IfHasCas() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove("somepath"); var op = new MultiMutation<dynamic>("thekey", builder, new Mock<IVBucket>().Object, new Mock<ITypeTranscoder>().Object, 10){Cas = 100}; Assert.IsTrue(op.CanRetry()); }
public void SubDocDelete_WillNotRetry_IfCasIsZero() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove("somepath"); var op = new SubDocDelete<dynamic>(builder, "thekey", new Mock<IVBucket>().Object, new Mock<ITypeTranscoder>().Object, 10) { Cas = 0 }; Assert.IsFalse(op.CanRetry()); }
public void MultiMutation_WillRetry_IfHasCas() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove("somepath"); var op = new MultiMutation <dynamic>("thekey", builder, new Mock <IVBucket>().Object, new Mock <ITypeTranscoder>().Object, 10) { Cas = 100 }; Assert.IsTrue(op.CanRetry()); }
public void SubDocDelete_WillNotRetry_IfCasIsZero() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove("somepath"); var op = new SubDocDelete <dynamic>(builder, "thekey", new Mock <IVBucket>().Object, new Mock <ITypeTranscoder>().Object, 10) { Cas = 0 }; Assert.IsFalse(op.CanRetry()); }
public void MultiMutate_Clone() { var mockedInvoker = new Mock <ISubdocInvoker>(); var builder = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove("somepath"); builder.ArrayPrepend("pathone", 10); var op = new MultiMutation <dynamic>("thekey", builder, new Mock <IVBucket>().Object, new Mock <ITypeTranscoder>().Object, 10) { Cas = 100 }; var cloned = (MultiMutation <dynamic>)op.Clone(); Assert.AreEqual(op, cloned); }
public void MultiMutate_Clone() { var mockedInvoker = new Mock<ISubdocInvoker>(); var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey"); builder.Remove("somepath"); builder.ArrayPrepend("pathone", 10); var op = new MultiMutation<dynamic>("thekey", builder, new Mock<IVBucket>().Object, new Mock<ITypeTranscoder>().Object, 10) { Cas = 100 }; var cloned = (MultiMutation<dynamic>) op.Clone(); Assert.AreEqual(op, cloned); }