mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added manual test subapplication for device commands.
This commit is contained in:
107
DiscImageChef.Tests.Devices/Main.cs
Normal file
107
DiscImageChef.Tests.Devices/Main.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Program.cs
|
||||
// Version : 1.0
|
||||
// Author(s) : Natalia Portillo
|
||||
//
|
||||
// Component : Component
|
||||
//
|
||||
// Revision : $Revision$
|
||||
// Last change by : $Author$
|
||||
// Date : $Date$
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Description
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2015 Claunia.com
|
||||
// ****************************************************************************/
|
||||
// //$Id$
|
||||
using System.Linq;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Devices;
|
||||
|
||||
namespace DiscImageChef.Tests.Devices
|
||||
{
|
||||
partial class MainClass
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
DicConsole.WriteLineEvent += System.Console.WriteLine;
|
||||
DicConsole.WriteEvent += System.Console.Write;
|
||||
DicConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine;
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
DeviceInfo[] devices = DiscImageChef.Devices.Device.ListDevices();
|
||||
|
||||
if(devices == null || devices.Length == 0)
|
||||
{
|
||||
DicConsole.WriteLine("No known devices attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
devices = devices.OrderBy(d => d.path).ToArray();
|
||||
|
||||
int item;
|
||||
string strDev;
|
||||
|
||||
while(true)
|
||||
{
|
||||
System.Console.Clear();
|
||||
|
||||
DicConsole.WriteLine("DiscImageChef device handling tests");
|
||||
|
||||
DicConsole.WriteLine("{6,-8}|{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}",
|
||||
"Path", "Vendor", "Model", "Serial", "Bus", "Supported?", "Number");
|
||||
DicConsole.WriteLine("{6,-8}|{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}",
|
||||
"----------------------", "----------------", "------------------------",
|
||||
"------------------------", "----------", "----------", "--------");
|
||||
for(int i = 0; i < devices.Length; i++)
|
||||
DicConsole.WriteLine("{6,-8}|{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", devices[i].path, devices[i].vendor, devices[i].model, devices[i].serial, devices[i].bus, devices[i].supported, i + 1);
|
||||
|
||||
DicConsole.Write("Please choose which drive to test (0 to exit): ");
|
||||
strDev = System.Console.ReadLine();
|
||||
if(!int.TryParse(strDev, out item))
|
||||
{
|
||||
DicConsole.WriteLine("Not a number. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item == 0)
|
||||
{
|
||||
DicConsole.WriteLine("Exiting...");
|
||||
return;
|
||||
}
|
||||
|
||||
if(item > devices.Length)
|
||||
{
|
||||
DicConsole.WriteLine("No such device. Press any key to continue...");
|
||||
System.Console.ReadKey();
|
||||
continue;
|
||||
}
|
||||
|
||||
Device(devices[item - 1].path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user