Example #1
0
        public async Task PathClient_CanGetParentDirectoryClient_WithContainerSAS()
        {
            // Arrange
            var parentDirName = DataLakeClientBuilder.GetNewDirectoryName();

            await using DisposingFileSystem test = await DataLakeClientBuilder.GetNewFileSystem();

            var fileName = DataLakeClientBuilder.GetNewFileName();
            DataLakeFileClient fileClient = InstrumentClient(
                GetServiceClient_DataLakeServiceSas_FileSystem(test.Container.Name)
                .GetFileSystemClient(test.FileSystem.Name)
                .GetRootDirectoryClient()
                .GetSubDirectoryClient(parentDirName)
                .GetFileClient(fileName));
            await fileClient.CreateAsync();

            // Act
            DataLakeDirectoryClient parentDirClient = fileClient.GetParentDirectoryClient();
            // make sure that client is functional
            var pathItems = await parentDirClient.GetPathsAsync().ToListAsync();

            // Assert
            Assert.AreEqual(fileClient.Path.GetParentPath(), parentDirClient.Path);
            Assert.AreEqual(fileClient.AccountName, parentDirClient.AccountName);
            Assert.IsNotNull(pathItems);
        }
Example #2
0
        public async Task PathClient_CanGetParentDirectoryClient()
        {
            // Arrange
            var parentDirName = DataLakeClientBuilder.GetNewDirectoryName();

            await using DisposingFileSystem test = await DataLakeClientBuilder.GetNewFileSystem();

            DataLakeFileClient fileClient = InstrumentClient(test.Container
                                                             .GetRootDirectoryClient()
                                                             .GetSubDirectoryClient(parentDirName)
                                                             .GetFileClient(DataLakeClientBuilder.GetNewFileName()));
            await fileClient.CreateAsync();

            // Act
            DataLakeDirectoryClient parentDirClient = fileClient.GetParentDirectoryClient();
            // make sure that client is functional
            var dirProperties = await parentDirClient.GetPropertiesAsync();

            // Assert
            Assert.AreEqual(fileClient.Path.GetParentPath(), parentDirClient.Path);
            Assert.AreEqual(fileClient.AccountName, parentDirClient.AccountName);
            Assert.IsNotNull(dirProperties);
        }