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 ArrayAddUnique_DoesNotThrowsArgumentException_WhenPathIsEmpty(string path)
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new MutateInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.ArrayAddUnique(path, 0);
        }
        public void ArrayAddUnique_DoesNotThrowsArgumentException_WhenPathIsEmpty(string path)
        {
            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new MutateInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.ArrayAddUnique(path, 0);
        }
Beispiel #4
0
        public void ArrayAddUnique_Single_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.ArrayAddUnique("path", "value", flags)
                         .Execute();

            Assert.AreSame(mockResult.Object, result);
            mockedInvoker.Verify(
                invoker => invoker.Invoke(It.Is <MutateInBuilder <dynamic> >(
                                              builder =>
                                              builder.FirstSpec().OpCode == OperationCode.SubArrayAddUnique &&
                                              builder.FirstSpec().Path == "path" &&
                                              builder.FirstSpec().Flags == expected &&
                                              (string)builder.FirstSpec().Value == "value"
                                              )
                                          ), Times.Once
                );
        }