[Ignore(\"为了测试并发插入的问题,屏蔽该方法\")]
public void GetComputerInfo()
...{
Thread[] threads = new Thread[1000];
for (int i = 0; i < 1000; i++)
...{
Thread t = new Thread(new ThreadStart(Func));
threads[i] = t;
}
for (int i = 0; i < 1000; i++)
...{
threads[i].Start();
}}
private void Func()
...{
mCompuerInfo = computerInfo.GetComputerInfo(1);
Assert.AreEqual(mCompuerInfo.ComputerName, \"YMF-XPWY\");
}
[Test]
public void GetComputerInfoByMAC()
...{
mCompuerInfo = computerInfo.GetComputerInfoByMAC(\"00:1B:FC:64:6C:A3\");
Assert.AreEqual(mCompuerInfo.ComputerName, \"YMF-XPWY\");//正常条件
mCompuerInfo = computerInfo.GetComputerInfoByMAC(\"00:sdfsdfsdf\");
Assert.AreEqual(mCompuerInfo, null);//边界条件
}
[Test]
public void TestInsertCPInfoWhileMorePeoper()
...{
Thread[] threads = new Thread[1000];
for (int i = 0; i < 1000; i++)
...{
j++;
threads[i] = new Thread(new ThreadStart(TestInsertCPInfo));
threads[i].Start();
}
}
private void TestInsertCPInfo()
...{
mCompuerInfo.AudioDapater = j.ToString();
mCompuerInfo.BrowserInfo = j.ToString();
mCompuerInfo.ComputerName = \"fw\";
mCompuerInfo.EthernetAddress = \"asdsad\";
mCompuerInfo.ExamSeatNo = j;
mCompuerInfo.IpAddress = \"192.168.0.1\";
mCompuerInfo.IsTestPassed = true; ;
mCompuerInfo.NotPassedError = \"yes\";
mCompuerInfo.OSName = \"OSName\";
mCompuerInfo.OSVersion = \"1.0.1\";
computerInfo.InsertCPInfo(mCompuerInfo);
}
}
文章来源于领测软件测试网 https://www.ltesting.net/