/// <exception cref="System.Exception"/> public virtual void TestDFInvalidPath() { // Generate a path that doesn't exist Random random = new Random(unchecked ((long)(0xDEADBEEFl))); FilePath file = null; byte[] bytes = new byte[64]; while (file == null) { random.NextBytes(bytes); string invalid = new string("/" + bytes); FilePath invalidFile = new FilePath(invalid); if (!invalidFile.Exists()) { file = invalidFile; } } DF df = new DF(file, 0l); try { df.GetMount(); } catch (FileNotFoundException e) { // expected, since path does not exist GenericTestUtils.AssertExceptionContains(file.GetName(), e); } }
/// <exception cref="System.Exception"/> public virtual void TestGetMountCurrentDirectory() { FilePath currentDirectory = new FilePath("."); string workingDir = currentDirectory.GetAbsoluteFile().GetCanonicalPath(); DF df = new DF(new FilePath(workingDir), 0L); string mountPath = df.GetMount(); FilePath mountDir = new FilePath(mountPath); Assert.True("Mount dir [" + mountDir.GetAbsolutePath() + "] should exist." , mountDir.Exists()); Assert.True("Mount dir [" + mountDir.GetAbsolutePath() + "] should be directory." , mountDir.IsDirectory()); Assert.True("Working dir [" + workingDir + "] should start with [" + mountPath + "].", workingDir.StartsWith(mountPath)); }