DotNet中获取系统信息(二)

    首次使用TDD,还有很多不大清楚,敬请高人指教!
    单元测试代码如下:
None.gif using  System;
None.gif
using  System.Net;
None.gif
using  NUnit.Framework;
None.gif
None.gif
namespace  SystemInfomation
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// Summary description for GetInfoFixture.
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    [TestFixture]
InBlock.gif    
public class SystemInfomationFixture
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private const string OS_VERION = "Microsoft Windows NT 5.2.3790.0";
InBlock.gif        
private const string MACHINE_NAME = "VC";
InBlock.gif        
private const string USER_NAME = "Vincent";
InBlock.gif        
private const string BOOT_MODE = "Normal";
InBlock.gif        
private const string LOGICAL_DRIVERS = @"A:\;C:\;D:\;E:\;F:\;G:\;H:\;I:\;J:\;K:\;L:\;M:\;O:\;";
InBlock.gif        
private const string IP_ADDR = "192.168.0.10 192.168.35.1 192.168.188.1 ";
InBlock.gif        
private const string DOMAIN_NAME = "VC";
InBlock.gif        
private const string SYSTEM_DIR = @"C:\Windows\System32";
InBlock.gif        
private const string TEMP_DIR = @"C:\DOCUME~1\VINCENT\LOCALS~1\TEMP";
InBlock.gif        
private const string FX_VVERSION = "1.1.4322.573";
InBlock.gif        
private const string PROCESSOR_NAME = "AMD Athlon(tm) XP 1600+";
InBlock.gif        
private const string PROCESSOR_IDENTIFIER = "x86 Family 6 Model 6 Stepping 2";
InBlock.gif        
private const string PROCESSOR_FREQUENCY = "1405 MHz";
InBlock.gif        
private const string BIOS_IDENTIFIER = "AT/AT COMPATIBLE";
InBlock.gif        
private const string SYSTEM_BISO_VERSION = "AMIINT - 10";
InBlock.gif        
private const string VIDEO_BISO_VERSION = "Version 3.11.01.24.00 ";
InBlock.gif        
private const string VIDEO_BISO_DATE = "10/31/01";
InBlock.gif        
private const string NETWORK_CARDS = "Realtek RTL8139 Family PCI Fast Ethernet NIC";
InBlock.gif
InBlock.gif        
private SystemInfomation info;
InBlock.gif
InBlock.gif        
public SystemInfomationFixture()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// TODO: Add constructor logic here
InBlock.gif            
//
ExpandedSubBlockEnd.gif
        }

InBlock.gif
InBlock.gif        [SetUp]
InBlock.gif        
public void Init()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            info 
= new SystemInfomation();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetOSVersion()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetOSVersion());
InBlock.gif            Assert.AreEqual(OS_VERION, info.GetOSVersion());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetMachineName()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetMachineName());
InBlock.gif            Assert.AreEqual(MACHINE_NAME, info.GetMachineName());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetBootMode()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetBootMode());
InBlock.gif            Assert.AreEqual(BOOT_MODE, info.GetBootMode());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetUserName()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetUserName());
InBlock.gif            Assert.AreEqual(USER_NAME, info.GetUserName());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetLogicalDrives()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string drivers = "";
InBlock.gif            
foreach (string drive in info.GetLogicalDrives())
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                drivers 
+= drive + ";";
ExpandedSubBlockEnd.gif            }

InBlock.gif            Console.WriteLine(drivers);
InBlock.gif            Assert.AreEqual(LOGICAL_DRIVERS, drivers);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetIPAddr()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string ip = "";
InBlock.gif            IPAddress[] ipAddress
= info.GetIPAddr();
InBlock.gif            
foreach (IPAddress address in ipAddress)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Console.Out.WriteLine(address.ToString());
InBlock.gif                ip 
+= address.ToString() + " ";
ExpandedSubBlockEnd.gif            }

InBlock.gif            Assert.AreEqual(IP_ADDR, ip);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetDomainName()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetDomainName());
InBlock.gif            Assert.AreEqual(DOMAIN_NAME, info.GetDomainName());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetUsedMemory()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetUsedMemory());
InBlock.gif            Assert.IsNotNull(info.GetUsedMemory());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetSystemDirectory()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetSystemDirectory());
InBlock.gif            Assert.AreEqual(SYSTEM_DIR.ToUpper(), info.GetSystemDirectory().ToUpper());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetTempDirectory()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetTempDirectory());
InBlock.gif            Assert.AreEqual(TEMP_DIR.ToUpper(), info.GetTempDirectory().ToUpper());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetFxVersion()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetFxVersion());
InBlock.gif            Assert.AreEqual(FX_VVERSION, info.GetFxVersion());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetOSRunnedTime()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            RunnedTime runnedTime 
= info.GetOSRunnedTime();
InBlock.gif            
string time = runnedTime.hour + " hour " + 
InBlock.gif                runnedTime.minute 
+ " minute " + runnedTime.second + " second";
InBlock.gif            Console.WriteLine(time);            
InBlock.gif            Assert.IsNotNull(time);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetProcessorName()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.WriteLine(info.GetProcessorName()[
0]);
InBlock.gif            Assert.AreEqual(PROCESSOR_NAME, info.GetProcessorName()[
0]);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetProcessorIdentifier()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.WriteLine(info.GetProcessorIdentifier()[
0]);
InBlock.gif            Assert.AreEqual(PROCESSOR_IDENTIFIER, info.GetProcessorIdentifier()[
0]);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetProcessorFrequency()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.WriteLine(info.GetProcessorFrequency()[
0]);
InBlock.gif            Assert.AreEqual(PROCESSOR_FREQUENCY, info.GetProcessorFrequency()[
0]);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        [Test]
InBlock.gif        
public void testGetBiosIdentifier()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Console.Out.WriteLine(info.GetBiosIdentifier());
InBlock.gif            Assert.AreEqual(BIOS_IDENTIFIER, info.GetBiosIdentifier());
ExpandedSubBlockEnd.gif     &#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值