Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomodo committed May 24, 2018
2 parents d133339 + 1023b43 commit c206641
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 463 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,17 @@ private void BackupFileStream_InitializeInstance(bool isNetwork)
}
catch (Exception ex)
{
var exType = ex.GetType();

gotException = exType == typeof(System.IO.IOException);

Console.WriteLine("\n\tCaught {0} Exception: [{1}] {2}", gotException ? "EXPECTED" : "UNEXPECTED", exType.Name, ex.Message);
var exName = ex.GetType().Name;
gotException = exName.Equals("IOException", StringComparison.OrdinalIgnoreCase);
Console.WriteLine("\tCaught EXPECTED Exception: [{0}] Message: [{1}]", exName, ex.Message);
}


Assert.IsTrue(gotException, "The exception is not caught, but is expected to.");


bfs.Unlock(0, 10);

#endregion // IOException


#region IOException #2

gotException = false;
Expand All @@ -99,23 +94,20 @@ private void BackupFileStream_InitializeInstance(bool isNetwork)
}
catch (Exception ex)
{
var exType = ex.GetType();

gotException = exType == typeof(System.IO.IOException);

Console.WriteLine("\n\tCaught {0} Exception: [{1}] {2}", gotException ? "EXPECTED" : "UNEXPECTED", exType.Name, ex.Message);
var exName = ex.GetType().Name;
gotException = exName.Equals("IOException", StringComparison.OrdinalIgnoreCase);
Console.WriteLine("\tCaught EXPECTED Exception: [{0}] Message: [{1}]", exName, ex.Message);
}


Assert.IsTrue(gotException, "The exception is not caught, but is expected to.");

#endregion // IOException #2


UnitTestConstants.Dump(bfs.ReadStreamInfo(), -10);
Console.WriteLine();

UnitTestConstants.Dump(bfs, -12);
UnitTestConstants.Dump(bfs, -14);
Console.WriteLine();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public void AlphaFS_Directory_EnumerateFileSystemEntryInfos_TypeFileSystemEntryI






private void Directory_EnumerateFileSystemEntryInfos_TypeFileSystemEntryInfo(bool isNetwork)
{
UnitTestConstants.PrintUnitTestHeader(isNetwork);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace AlphaFS.UnitTest
{
Expand All @@ -37,6 +38,21 @@ public void AlphaFS_Directory_GetFileSystemEntryInfo_LocalAndNetwork_Success()
}


[TestMethod]
public void AlphaFS_Directory_GetFileSystemEntryInfo_LogicalDrives_Local_Success()
{
Directory_GetFileSystemEntryInfo_LogicalDrives();
}


[TestMethod]
public void AlphaFS_Directory_GetFileSystemEntryInfo_CatchDirectoryNotFoundException_FileExistsWithSameNameAsDirectory_LocalAndNetwork_Success()
{
Directory_GetFileSystemEntryInfo_CatchDirectoryNotFoundException_FileExistsWithSameNameAsDirectory(false);
Directory_GetFileSystemEntryInfo_CatchDirectoryNotFoundException_FileExistsWithSameNameAsDirectory(true);
}




private void Directory_GetFileSystemEntryInfo(bool isNetwork)
Expand Down Expand Up @@ -64,6 +80,85 @@ private void Directory_GetFileSystemEntryInfo(bool isNetwork)
Assert.IsTrue((fsei.Attributes & System.IO.FileAttributes.Directory) != 0, "The Directory attribute is not found, but is expected.");
Assert.AreEqual(tempPath, fsei.FullPath, "The paths are not equal, but are expected to be.");

Console.WriteLine();
}


private void Directory_GetFileSystemEntryInfo_LogicalDrives()
{
UnitTestConstants.PrintUnitTestHeader(false);


var drives = Alphaleonis.Win32.Filesystem.Directory.EnumerateLogicalDrives().ToList();

foreach (var drive in drives)
{
Console.WriteLine("\nInput Logical Drive: [{0}]", drive.Name);

try
{
var fsei = Alphaleonis.Win32.Filesystem.Directory.GetFileSystemEntryInfo(drive.Name);
UnitTestConstants.Dump(fsei, -19);


Assert.IsTrue(fsei.GetType().IsEquivalentTo(typeof(Alphaleonis.Win32.Filesystem.FileSystemEntryInfo)));
Assert.IsTrue((fsei.Attributes & System.IO.FileAttributes.Directory) != 0, "The Directory attribute is not found, but is expected.");


// Fixed local drives should have these attributes.
if (new Alphaleonis.Win32.Filesystem.DriveInfo(drive.Name).DriveType == System.IO.DriveType.Fixed)
{
Assert.IsTrue((fsei.Attributes & System.IO.FileAttributes.Hidden) != 0, "The Hidden attribute is not found, but is expected.");
Assert.IsTrue((fsei.Attributes & System.IO.FileAttributes.System) != 0, "The System attribute is not found, but is expected.");
}


Assert.AreEqual(".", fsei.FileName, "The file names are not equal, but are expected to be.");
Assert.AreEqual(drive.Name, fsei.FullPath, "The full paths are not equal, but are expected to be.");
}
catch (Exception ex)
{
Console.WriteLine("\n\tCaught UNEXPECTED Exception: [{0}] {1}", ex.GetType().Name, ex.Message);
}


Console.WriteLine();
}
}


private void Directory_GetFileSystemEntryInfo_CatchDirectoryNotFoundException_FileExistsWithSameNameAsDirectory(bool isNetwork)
{
var path = UnitTestConstants.NotepadExe;

if (!System.IO.File.Exists(path))
Assert.Inconclusive("Test ignored because {0} was not found.", path);


UnitTestConstants.PrintUnitTestHeader(isNetwork);

var tempPath = path;
if (isNetwork)
tempPath = Alphaleonis.Win32.Filesystem.Path.LocalToUnc(tempPath);


Console.WriteLine("\nInput Directory Path: [{0}]", tempPath);


var gotException = false;
try
{
Alphaleonis.Win32.Filesystem.Directory.GetFileSystemEntryInfo(tempPath);
}
catch (Exception ex)
{
var exName = ex.GetType().Name;
gotException = exName.Equals("DirectoryNotFoundException", StringComparison.OrdinalIgnoreCase);
Console.WriteLine("\n\tCaught {0} Exception: [{1}] {2}", gotException ? "EXPECTED" : "UNEXPECTED", exName, ex.Message);
}
Assert.IsTrue(gotException, "The exception is not caught, but is expected to.");


Console.WriteLine();
}
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit c206641

Please sign in to comment.