コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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
                );
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }