public async Task <string> CreateAsync(string path, object data, List <ACL> acl, CreateMode mode) { if (path == null) { throw new ArgumentNullException("Missing value for path"); } if (acl == null || acl.Count == 0) { throw new ArgumentNullException("Missing value for ACL"); } byte[] bytes = data == null ? null : Serialize(data); return(await RetryUntilConnected(async() => await _connection.CreateAsync(path, bytes, acl, mode))); }
public async Task TestSequentials() { _connection = EstablishConnection(); string sequentialPath = await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL); int firstSequential = int.Parse(sequentialPath.Substring(2)); Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == sequentialPath); Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL)); Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL)); Assert.True("/b" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == await _connection.CreateAsync("/b", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL)); Assert.True("/b" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == await _connection.CreateAsync("/b", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL)); Assert.True("/a" + ZKPathUtil.LeadingZeros(firstSequential++, 10) == await _connection.CreateAsync("/a", new byte[0], CreateMode.EPHEMERAL_SEQUENTIAL)); _connection.Close(); _connection = null; }