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);
        }
Exemple #2
0
        public void ArrayAppend_DoesNotThrowArgumentException_WhenPathIsEmpty(string path)
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.ArrayAppend(path, 0, false);
        }
Exemple #3
0
        public void ArrayAppend_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.ArrayAppend("path", flags, value)
                         .Execute();

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

            Assert.AreSame(mockResult.Object, result);
            mockedInvoker.Verify(
                invoker => invoker.Invoke(It.Is <MutateInBuilder <dynamic> >(
                                              builder =>
                                              builder.FirstSpec().OpCode == OperationCode.SubArrayPushLast &&
                                              builder.FirstSpec().Path == "path" &&
                                              builder.FirstSpec().PathFlags == pathFlags &&
                                              builder.FirstSpec().DocFlags == docFlags &&
                                              (string)builder.FirstSpec().Value == "value"
                                              )
                                          ), Times.Once
                );
        }
        public void ArrayAppend_DoesNotThrowArgumentException_WhenPathIsEmpty(string path)
        {
            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(),  "thekey");

            builder.ArrayAppend(path, 0, false);
        }