コード例 #1
0
        public async Task GetChildrenTest()
        {
            string path       = $"/asyncchildren{Guid.NewGuid()}";
            string child1path = "child1";
            string child2path = "child2";

            using (ZooKeeper zk = CreateClient())
            {
                await zk.CreateAsync(path, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent);

                Assert.That(await zk.GetChildrenAsync(path, false), Is.Empty);

                await Task.WhenAll(zk.CreateAsync($"{path}/{child1path}", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent),
                                   zk.CreateAsync($"{path}/{child2path}", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent)).ConfigureAwait(false);

                Assert.That(await zk.GetChildrenAsync(path, false), Is.EquivalentTo(new[] { child1path, child2path }));
            }
        }