public void Maintain_Exsiting_Subdoc_Array_Signatures()
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.ArrayAppend(1);
            builder.ArrayAppend(1, false);
            builder.ArrayAppend("key", 1);
            builder.ArrayAppend("key", 1, false); // doesn't work with bools but other data types work
            //builder.ArrayAppend("key", 1, 2, 3); // already conflicted with (bool, params) & (string, bool, params)
            builder.ArrayAppend("key", true, 1, 2, 3);

            builder.ArrayPrepend(1);
            builder.ArrayPrepend(1, false);
            builder.ArrayPrepend("key", 1);
            builder.ArrayPrepend("key", 1, false); // doesn't work with bools but other data types work
            //builder.ArrayPrepend("key", 1, 2, 3); // already conflicted with (bool, params) & (string, bool, params)
            builder.ArrayPrepend("key", true, 1, 2, 3);

            builder.ArrayInsert("key", 1);
            builder.ArrayInsert("key", 1, false);
            builder.ArrayInsert("key", 1, 2, 3);
            builder.ArrayInsert("key", true, 1, 2, 3);

            builder.ArrayAddUnique(1);
            builder.ArrayAddUnique(1, false);
            builder.ArrayAddUnique("key", 1);
            builder.ArrayAddUnique("key", 1, false);
        }
Beispiel #2
0
        public void ArrayPrepend_DoesNotThrowArgumentException_WhenPathIsEmpty(string path)
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.ArrayPrepend(path, 0, false);
        }
Beispiel #3
0
        public void ArrayPrepend_Multiple_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 value  = new object[] { 1, 2, 3 };
            var result = mutateBuilder.ArrayPrepend("path", flags, value)
                         .Execute();

            Assert.AreSame(mockResult.Object, result);
            mockedInvoker.Verify(
                invoker => invoker.Invoke(It.Is <MutateInBuilder <dynamic> >(
                                              builder =>
                                              builder.FirstSpec().OpCode == OperationCode.SubArrayPushFirst &&
                                              builder.FirstSpec().Path == "path" &&
                                              builder.FirstSpec().Flags == expected &&
                                              builder.FirstSpec().Value == value
                                              )
                                          ), Times.Once
                );
        }
        public void ArrayPrepend_Single_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 <MutateInBuilder <dynamic> >()))
            .Returns(mockResult.Object);

            var mutateBuilder = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey");

            var result = mutateBuilder.ArrayPrepend("path", "value", pathFlags, docFlags)
                         .Execute();

            Assert.AreSame(mockResult.Object, result);
            mockedInvoker.Verify(
                invoker => invoker.Invoke(It.Is <MutateInBuilder <dynamic> >(
                                              builder =>
                                              builder.FirstSpec().OpCode == OperationCode.SubArrayPushFirst &&
                                              builder.FirstSpec().Path == "path" &&
                                              builder.FirstSpec().PathFlags == pathFlags &&
                                              builder.FirstSpec().DocFlags == docFlags &&
                                              (string)builder.FirstSpec().Value == "value"
                                              )
                                          ), Times.Once
                );
        }
        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 ArrayPrepend_DoesNotThrowArgumentException_WhenPathIsEmpty(string path)
        {
            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.ArrayPrepend(path, 0, false);
        }
        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);
        }