This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…irectoryId to return a unique file or directory identifier. -Implemented #357: Added new Windows 10 property: FILE_DAX_VOLUME to VolumeInfo class. -Added new Windows 10 property: FILE_DAX_VOLUME to VolumeInfo class. -Renamed some native enums and structs to their (original) WIN32 name. -Update some unit tests.
- Loading branch information
Yomodo
authored and
Yomodo
committed
Jun 26, 2017
1 parent
47cc905
commit f59b649
Showing
158 changed files
with
2,231 additions
and
1,492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
....UnitTest/ByHandleFileInfo Class/AlphaFS_Directory_GetFileInfo_LocalAndNetwork_Success.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* Copyright (C) 2008-2017 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace AlphaFS.UnitTest | ||
{ | ||
[TestClass] | ||
public partial class ByHandleFileInfoTest | ||
{ | ||
// Pattern: <class>_<function>_<scenario>_<expected result> | ||
|
||
|
||
[TestMethod] | ||
public void AlphaFS_Directory_GetFileInfoByHandle_LocalAndNetwork_Success() | ||
{ | ||
Directory_GetFileInfoByHandle(false); | ||
Directory_GetFileInfoByHandle(true); | ||
} | ||
|
||
|
||
|
||
|
||
private void Directory_GetFileInfoByHandle(bool isNetwork) | ||
{ | ||
UnitTestConstants.PrintUnitTestHeader(isNetwork); | ||
|
||
var tempPath = System.IO.Path.GetTempPath(); | ||
if (isNetwork) | ||
tempPath = Alphaleonis.Win32.Filesystem.Path.LocalToUnc(tempPath); | ||
|
||
|
||
using (var rootDir = new TemporaryDirectory(tempPath, MethodBase.GetCurrentMethod().Name)) | ||
{ | ||
var folder = rootDir.RandomDirectoryFullPath; | ||
Console.WriteLine("\nInput Directory Path: [{0}]]", folder); | ||
|
||
|
||
var dirInfo = new System.IO.DirectoryInfo(folder); | ||
dirInfo.Create(); | ||
|
||
|
||
var bhfi = Alphaleonis.Win32.Filesystem.Directory.GetFileInfoByHandle(dirInfo.FullName); | ||
Assert.IsTrue(UnitTestConstants.Dump(bhfi, -18)); | ||
|
||
|
||
Assert.AreEqual(dirInfo.CreationTimeUtc, bhfi.CreationTimeUtc); | ||
Assert.AreEqual(dirInfo.LastAccessTimeUtc, bhfi.LastAccessTimeUtc); | ||
Assert.AreEqual(dirInfo.LastWriteTimeUtc, bhfi.LastWriteTimeUtc); | ||
|
||
} | ||
|
||
Console.WriteLine(); | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...itTest/ByHandleFileInfo Class/AlphaFS_File_GetFileInfoByHandle_LocalAndNetwork_Success.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* Copyright (C) 2008-2017 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace AlphaFS.UnitTest | ||
{ | ||
public partial class ByHandleFileInfoTest | ||
{ | ||
// Pattern: <class>_<function>_<scenario>_<expected result> | ||
|
||
|
||
[TestMethod] | ||
public void AlphaFS_File_GetFileInfoByHandle_LocalAndNetwork_Success() | ||
{ | ||
File_GetFileInfoByHandle(false); | ||
File_GetFileInfoByHandle(true); | ||
} | ||
|
||
|
||
|
||
|
||
private void File_GetFileInfoByHandle(bool isNetwork) | ||
{ | ||
UnitTestConstants.PrintUnitTestHeader(isNetwork); | ||
|
||
var tempPath = System.IO.Path.GetTempPath(); | ||
if (isNetwork) | ||
tempPath = Alphaleonis.Win32.Filesystem.Path.LocalToUnc(tempPath); | ||
|
||
|
||
using (var rootDir = new TemporaryDirectory(tempPath, MethodBase.GetCurrentMethod().Name)) | ||
{ | ||
var file = rootDir.RandomFileFullPath; | ||
Console.WriteLine("\nInput File Path: [{0}]]", file); | ||
|
||
|
||
var fileInfo = new System.IO.FileInfo(file); | ||
|
||
using (var stream = fileInfo.OpenWrite()) | ||
{ | ||
var size = new Random().Next(1000, 10000); | ||
stream.Write(new byte[size], 0, size); | ||
|
||
var bhfi = Alphaleonis.Win32.Filesystem.File.GetFileInfoByHandle(stream.SafeFileHandle); | ||
Assert.IsTrue(UnitTestConstants.Dump(bhfi, -18)); | ||
|
||
|
||
Assert.AreEqual(fileInfo.CreationTimeUtc, bhfi.CreationTimeUtc); | ||
Assert.AreEqual(fileInfo.LastAccessTimeUtc, bhfi.LastAccessTimeUtc); | ||
Assert.AreEqual(fileInfo.LastWriteTimeUtc, bhfi.LastWriteTimeUtc); | ||
|
||
Assert.AreEqual(fileInfo.Length, bhfi.FileSize); | ||
} | ||
} | ||
|
||
Console.WriteLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...S.UnitTest/CRC Class/AlphaFS_Crc32_StaticDefaultSeedAndPolynomialWithShortAsciiString2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Copyright (C) 2008-2017 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using System; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AlphaFS.UnitTest | ||
{ | ||
public partial class CRCTest | ||
{ | ||
// Pattern: <class>_<function>_<scenario>_<expected result> | ||
|
||
|
||
[TestMethod] | ||
public void AlphaFS_Crc32_StaticDefaultSeedAndPolynomialWithShortAsciiString2() | ||
{ | ||
using (var crc32 = new Alphaleonis.Win32.Security.Crc32()) | ||
{ | ||
var text = UnitTestConstants.StreamArrayContent[1]; | ||
var hash = crc32.ComputeHash(System.Text.Encoding.ASCII.GetBytes(text)).Aggregate(string.Empty, (current, b) => current + b.ToString("x2").ToLower()); | ||
|
||
Console.WriteLine("Input text: {0}", text); | ||
Console.WriteLine("\n\tCRC32: {0}", hash); | ||
|
||
Assert.AreEqual("85cd3815", hash); | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...UnitTest/CRC Class/AlphaFS_Crc64Iso_StaticDefaultSeedAndPolynomialWithShortAsciiString.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Copyright (C) 2008-2017 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
using System; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AlphaFS.UnitTest | ||
{ | ||
public partial class CRCTest | ||
{ | ||
// Pattern: <class>_<function>_<scenario>_<expected result> | ||
|
||
|
||
[TestMethod] | ||
public void AlphaFS_Crc64Iso_StaticDefaultSeedAndPolynomialWithShortAsciiString() | ||
{ | ||
using (var crc64 = new Alphaleonis.Win32.Security.Crc64()) | ||
{ | ||
var text = UnitTestConstants.StreamArrayContent[0]; | ||
var hash = crc64.ComputeHash(System.Text.Encoding.ASCII.GetBytes(text)).Aggregate(string.Empty, (current, b) => current + b.ToString("x2").ToLower()); | ||
|
||
Console.WriteLine("Input text: {0}", text); | ||
Console.WriteLine("\n\tCRC64: {0}", hash); | ||
|
||
Assert.AreEqual("724293319a37353f", hash); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.