Exemple #1
0
        public async Task test_client_with_deadline()
        {
            var channel = new Channel($"{HOSTNAME}:{PORT}", ChannelCredentials.Insecure);
            var client  = new DgraphNetClient(new DgraphConnection(channel), 1);

            var op = new Operation {
                Schema = "name: string @index(exact) ."
            };

            // Alters schema without exceeding the given deadline.
            await client.AlterAsync(op);

            // Creates a blocking stub directly, in order to force a deadline to be exceeded.
            var anyConnectionMethod = typeof(DgraphNetClient)
                                      .GetMethod("AnyConnection", BindingFlags.NonPublic | BindingFlags.Instance);

            var(conn, callOptions) = (ValueTuple <DgraphConnection, CallOptions>)anyConnectionMethod
                                     .Invoke(client, Array.Empty <object>());

            var stub = conn.Client;

            Thread.Sleep(1001);

            Assert.Throws <RpcException>(() => stub.Alter(op, callOptions), "Deadline should have been exceeded");
        }
Exemple #2
0
        public async Task OneTimeSetUp()
        {
            var pool = new DgraphConnectionPool()
                       .Add(new Channel($"{HOSTNAME}:{PORT}", ChannelCredentials.Insecure));

            _client = new DgraphNetClient(pool);

            await _client.AlterAsync(new Operation { DropAll = true });
        }