Ejemplo n.º 1
0
        public void MutationBuilderPreservesArgs(
            string setJson,
            string setNQ,
            string deleteJson,
            string deleteNQ,
            string cond
            )
        {
            var mb = new MutationBuilder {
                SetJson    = setJson,
                SetNquads  = setNQ,
                DeleteJson = deleteJson,
                DelNquads  = deleteNQ,
                Cond       = cond
            };

            mb.Mutation.Should().Be(
                new Api.Mutation {
                SetJson    = ByteString.CopyFromUtf8(setJson ?? ""),
                SetNquads  = ByteString.CopyFromUtf8(setNQ ?? ""),
                DeleteJson = ByteString.CopyFromUtf8(deleteJson ?? ""),
                DelNquads  = ByteString.CopyFromUtf8(deleteNQ ?? ""),
                Cond       = cond ?? ""
            }
                );
        }
        public void TestMutationQuery_WithParameter()
        {
            //

            const string query = @"mutation Test($id:Int!){
			  TestQuery(id:$id){
					boolField
				}
			}"            ;

            //

            const long paramId = 12;

            //

            var queryBuilder = new MutationBuilder("Test");

            //

            queryBuilder.WithAction(new MutationActionBuilder("TestQuery")
                                    .WithParameter(new Parameter <long>("id", paramId, "id"))
                                    .WithField(new NodeField("boolField")))
            .Build();

            //

            string parsedQuery         = Regex.Replace(query, "[ \n\r\t]", "");
            string parsedMutationQuery = Regex.Replace(queryBuilder.Query, "[ \n\r\t]", "");

            //

            int compareResult = string.Compare(parsedQuery, parsedMutationQuery, System.StringComparison.InvariantCultureIgnoreCase);

            //

            Assert.IsNotNull(queryBuilder.Query);
            Assert.AreEqual(0, compareResult);
        }
Ejemplo n.º 3
0
        public void MutationRequestsPreservesArgs(string query, bool?commit, bool withMutation)
        {
            var builder = new RequestBuilder();

            if (query != null)
            {
                builder.Query = query;
            }
            if (commit != null)
            {
                builder.CommitNow = commit.Value;
            }

            var mb = new MutationBuilder()
            {
                SetJson = "json"
            };

            if (withMutation)
            {
                builder.WithMutations(mb);
            }

            var req = builder.Request;

            req.Query.Should().Be(query ?? "");
            req.CommitNow.Should().Be(commit ?? false);

            if (withMutation)
            {
                req.Mutations.Count.Should().Be(1);
                req.Mutations[0].Should().Be(mb.Mutation);
            }
            else
            {
                req.Mutations.Count.Should().Be(0);
            }
        }