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

Add additional Network.Host methods. #414

Merged
merged 29 commits into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
70056fa
Initial commit: Network List Manager.
Yomodo Feb 5, 2018
63745e5
Completed.
Yomodo Feb 5, 2018
bfc9041
-Fixed NetworkConnectionInfo for .NET 3.5 build;
Yomodo Feb 7, 2018
54365b7
Replace properties AdapterID, AdapterName and AdapterDescription with…
Yomodo Feb 7, 2018
06f5c9d
Merge branch 'develop' into NetworkConnection
Yomodo Feb 7, 2018
f07a2e5
Merge branch 'develop' into NetworkConnection
Yomodo Feb 7, 2018
bcc103f
NetStatistics
Yomodo Feb 9, 2018
faae479
-Fixed compile error;
Yomodo Feb 9, 2018
31348cd
Implemented ServerStatisticsInfo.
Yomodo Feb 9, 2018
cc73f0a
Code improvement, work in progress.
Yomodo Feb 10, 2018
b21b288
Added class WorkstationStatisticsInfo.
Yomodo Feb 10, 2018
66d358b
Merge branch 'NetStatistics' into NetworkConnection
Yomodo Feb 10, 2018
86543f3
Fixed project file.
Yomodo Feb 10, 2018
f7255b5
Initial commit, work in progress.
Yomodo Feb 10, 2018
e07bd9b
Code improvement, work in progress.
Yomodo Feb 11, 2018
0b29017
Code improvement.
Yomodo Feb 11, 2018
1d07550
Renamed SessionInfoLevel to SessionLevel.
Yomodo Feb 11, 2018
3ded2e5
Merge branch 'develop' into NetworkConnection
Yomodo Feb 16, 2018
84c2c4f
Added ProcessContext static class that determine the context of the c…
Yomodo Feb 16, 2018
6dd2364
Merge branch 'ProcessContext2' into NetworkConnection
Yomodo Feb 16, 2018
0b5e33b
Merge branch 'develop' into ProcessContext2
Yomodo Feb 17, 2018
ed3f988
Merge branch 'ProcessContext2' into NetworkConnection
Yomodo Feb 17, 2018
6ec583f
Merge branch 'develop' into ProcessContext2
Yomodo Feb 19, 2018
c1e017e
Merge branch 'develop' into NetworkConnection
Yomodo Feb 19, 2018
9baebd1
Merge branch 'develop' into ProcessContext2
Yomodo Feb 19, 2018
f1a6956
Merge branch 'ProcessContext2' into NetworkConnection
Yomodo Feb 19, 2018
160c068
Merge branch 'develop' into NetworkConnection
Yomodo Feb 19, 2018
8ce1e9d
Merge branch 'develop' into NetworkConnection
Yomodo Feb 20, 2018
691f2ba
Merge branch 'develop' into NetworkConnection
Yomodo Feb 20, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* 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;

namespace AlphaFS.UnitTest
{
public partial class AlphaFS_HostTest
{
[TestMethod]
public void AlphaFS_Host_GetServerStatistics_Local_Success()
{
UnitTestConstants.PrintUnitTestHeader(false);

if (!UnitTestConstants.IsAdmin())
Assert.Inconclusive();


var serverStatistics = Alphaleonis.Win32.Network.Host.GetServerStatistics();

UnitTestConstants.Dump(serverStatistics, -22);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* 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;

namespace AlphaFS.UnitTest
{
public partial class AlphaFS_HostTest
{
[TestMethod]
public void AlphaFS_Host_GetWorkstationStatistics_Local_Success()
{
UnitTestConstants.PrintUnitTestHeader(false);

if (!UnitTestConstants.IsAdmin())
Assert.Inconclusive();


var workstationStat = Alphaleonis.Win32.Network.Host.GetWorkstationStatistics();

UnitTestConstants.Dump(workstationStat, -36);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* 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;
using Alphaleonis.Win32.Network;

namespace AlphaFS.UnitTest
{
public partial class AlphaFS_HostTest
{
[TestMethod]
public void AlphaFS_Host_EnumerateNetworkConnections_Local_Success()
{
UnitTestConstants.PrintUnitTestHeader(false);


var networkConnectionCount = 0;

foreach (var networkConnection in Host.EnumerateNetworkConnections().OrderBy(networkConnection => networkConnection.NetworkInfo.Name))
{
Console.WriteLine("\n#{0:000}\tNetwork: [{1}]", ++networkConnectionCount, networkConnection.NetworkInfo.Name);


UnitTestConstants.Dump(networkConnection, -21);

UnitTestConstants.Dump(networkConnection.NetworkInfo, -21, true);

UnitTestConstants.Dump(networkConnection.NetworkInterface, -20, true);


Console.WriteLine();
}


if (networkConnectionCount == 0)
Assert.Inconclusive("No network connections enumerated, but it is expected.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* 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;
using Alphaleonis.Win32.Network;

namespace AlphaFS.UnitTest
{
public partial class AlphaFS_HostTest
{
[TestMethod]
public void AlphaFS_Host_EnumerateNetworks_Local_Success()
{
UnitTestConstants.PrintUnitTestHeader(false);


var networkCount = 0;

foreach (var network in Host.EnumerateNetworks().OrderBy(network => network.Name))
{
Console.WriteLine("\n#{0:000}\tNetwork: [{1}]", ++networkCount, network.Name);


UnitTestConstants.Dump(network, -21);


if (null != network.Connections)
{
foreach (var connection in network.Connections)
{
UnitTestConstants.Dump(connection, -21, true);

UnitTestConstants.Dump(connection.NetworkInterface, -20, true);
}
}


Console.WriteLine();
}


if (networkCount == 0)
Assert.Inconclusive("No networks enumerated, but it is expected.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* 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;

namespace AlphaFS.UnitTest
{
public partial class AlphaFS_HostTest
{
// Pattern: <class>_<function>_<scenario>_<expected result>

[TestMethod]
public void AlphaFS_Host_EnumerateSessions_Local_Success()
{
var host = UnitTestConstants.LocalHost;

EnumerateSessions(host);
}




private void EnumerateSessions(string host)
{
UnitTestConstants.PrintUnitTestHeader(false);

Console.WriteLine("\nInput Host: [{0}]", host);


var sessionCount = 0;

foreach (var sessionsInfo in Alphaleonis.Win32.Network.Host.EnumerateSessions(host))
{
//Console.WriteLine("\n\t#{0:000}\tShare: [{1}]", ++cnt, shareInfo);

if (UnitTestConstants.Dump(sessionsInfo, -16))
sessionCount++;

Console.WriteLine();
}


if (sessionCount == 0)
Assert.Inconclusive("No sessions enumerated, but it is expected. Try another server name if applicable.");


Console.WriteLine();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ public partial class AlphaFS_HostTest
// Pattern: <class>_<function>_<scenario>_<expected result>

[TestMethod]
public void AlphaFS_Host_EnumerateOpenConnections_Network_Success()
public void AlphaFS_Host_EnumerateOpenConnections_Local_Success()
{
var host = "localhost"; //UnitTestConstants.LocalHost;
var host = UnitTestConstants.LocalHost;
var share = UnitTestConstants.SysDrive[0] + Alphaleonis.Win32.Filesystem.Path.NetworkDriveSeparator;

// Create an active connection to the "remote" host.
var currentDir = System.IO.Directory.GetCurrentDirectory();
System.IO.Directory.SetCurrentDirectory(@"\\" + host + @"\" + share);
System.IO.Directory.SetCurrentDirectory(Alphaleonis.Win32.Filesystem.Path.UncPrefix + host + Alphaleonis.Win32.Filesystem.Path.DirectorySeparator + share);

EnumerateOpenConnections(host, share, true);
EnumerateOpenConnections(host, share);

System.IO.Directory.SetCurrentDirectory(currentDir);
}




private void EnumerateOpenConnections(string host, string share, bool isNetwork)
private void EnumerateOpenConnections(string host, string share)
{
UnitTestConstants.PrintUnitTestHeader(isNetwork);
UnitTestConstants.PrintUnitTestHeader(false);

if (!UnitTestConstants.IsAdmin())
Assert.Inconclusive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,19 @@ public partial class AlphaFS_HostTest
// Pattern: <class>_<function>_<scenario>_<expected result>

[TestMethod]
public void AlphaFS_Host_EnumerateOpenResources_Network_Success()
public void AlphaFS_Host_EnumerateOpenResources_Local_Success()
{
var host = "localhost"; //UnitTestConstants.LocalHost;
var share = UnitTestConstants.SysDrive[0] + Alphaleonis.Win32.Filesystem.Path.NetworkDriveSeparator;
var host = UnitTestConstants.LocalHost;

// Create an active connection to the "remote" host.
var currentDir = System.IO.Directory.GetCurrentDirectory();
System.IO.Directory.SetCurrentDirectory(@"\\" + host + @"\" + share);

//EnumerateOpenResources(UnitTestConstants.LocalHost, true);
EnumerateOpenResources(host, true);

System.IO.Directory.SetCurrentDirectory(currentDir);
EnumerateOpenResources(host);
}




private void EnumerateOpenResources(string host, bool isNetwork)
private void EnumerateOpenResources(string host)
{
UnitTestConstants.PrintUnitTestHeader(isNetwork);
UnitTestConstants.PrintUnitTestHeader(false);

if (!UnitTestConstants.IsAdmin())
Assert.Inconclusive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ public partial class AlphaFS_HostTest
// Pattern: <class>_<function>_<scenario>_<expected result>

[TestMethod]
public void AlphaFS_Host_EnumerateShares_Network_Success()
public void AlphaFS_Host_EnumerateShares_Local_Success()
{
var host = UnitTestConstants.LocalHost;

EnumerateShares(host, true);
EnumerateShares(host);
}




private void EnumerateShares(string host, bool isNetwork)
private void EnumerateShares(string host)
{
UnitTestConstants.PrintUnitTestHeader(isNetwork);
UnitTestConstants.PrintUnitTestHeader(false);

Console.WriteLine("\nInput Host: [{0}]", host);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void AlphaFS_Host_GetUncName_Network_Success()
Console.WriteLine("Host.GetUncName(): [{0}]", hostUncName);


Assert.IsTrue(hostUncName.StartsWith(@"\\"));
Assert.IsTrue(hostUncName.StartsWith(Alphaleonis.Win32.Filesystem.Path.UncPrefix));

Assert.AreEqual(Alphaleonis.Win32.Filesystem.Path.UncPrefix + Environment.MachineName, hostUncName);
}
Expand Down
Loading