????????????????
???????????? ???????[ 2011/12/20 14:24:27 ] ????????
/// <remarks>
/// For the built-in <see cref="Connection"/> types
/// ??i.e. DesktopConnection?? NicConnection?? WirelessConnection?? WiredConnection????
/// only the class name is required. For user created types?? the fully qualified
/// class name is required.
/// </remarks>
public static Connection CreateConnection??string connectionType?? int price??
{
Guard.StringNotNullOrEmpty??connectionType?? "connectionType"????
if ??price < 0??
{
throw new ArgumentOutOfRangeException??"price"????
}
Connection connection;
switch ??connectionType??
{
case DesktopConnection:
connection = new DesktopConnection??DesktopConnection?? price????
break;
case NicConnection:
connection = new NicConnection??NicConnection?? price????
break;
case WirelessConnection:
connection = new WirelessConnection??WirelessConnection?? price????
break;
case WiredConnection:
connection = new WiredConnection??WiredConnection?? price????
break;
default:
try
{
Type connectionTypeToCreate = Type.GetType??connectionType?? true????
Object createdObject = Activator.CreateInstance??connectionTypeToCreate?? connectionTypeToCreate.Name?? price????
connection = createdObject as Connection;
}
catch??TypeLoadException ex??
{
throw new ConnectionMonitorException??"Unsupported connection type."?? ex????
}
if ??connection == null??
{
throw new ConnectionMonitorException??"Unsupported connection type."????
}
break;
}
return connection;
}
}
}
????????ConnectionFactoryFixture.cs?? ?????????CreateConnection????????????????????????????????
using System;
using System.Text;
using System.Collections.Generic;
using NUnit.Framework;
using Microsoft.Practices.SmartClient.ConnectionMonitor.Implementations;namespace Microsoft.Practices.SmartClient.ConnectionMonitor.Tests
{
/// <summary>
/// Summary description for ConnectionFactoryFixture
/// </summary>
[TestFixture]
public class ConnectionFactoryFixture
{
public ConnectionFactoryFixture????
{
}
[Test]
public void CanCreateDesktopConnection????
{
Connection connection = ConnectionFactory.CreateConnection??"DesktopConnection"?? 1????
Assert.IsNotNull??connection????
Assert.IsTrue??connection is DesktopConnection????
}
[Test]
public void CanCreateNicConnection????
{
Connection connection = ConnectionFactory.CreateConnection??"NicConnection"?? 1????
Assert.IsNotNull??connection????
Assert.IsTrue??connection is NicConnection????
}
[Test]
public void CanCreateWirelessConnection????
{
Connection connection = ConnectionFactory.CreateConnection??"WirelessConnection"?? 1????
Assert.IsNotNull??connection????
Assert.IsTrue??connection is WirelessConnection????
}
[Test]
public void CanCreateWiredConnection????
{
Connection connection = ConnectionFactory.CreateConnection??"WiredConnection"?? 1????
Assert.IsNotNull??connection????
Assert.IsTrue??connection is WiredConnection????
}
[Test]
public void CanCreateMyCustomConnection????
{
Connection connection = ConnectionFactory.CreateConnection??"Microsoft.Practices.SmartClient.ConnectionMonitor.Tests.MyCustomConnection??SmartClient.ConnectionMonitor.Tests"?? 1????
Assert.IsNotNull??connection????
Assert.IsTrue??connection is MyCustomConnection????
}
[Test]
[ExpectedException??typeof??ConnectionMonitorException????]
public void CreateConnectionThrowsWhenPassedBadType????
{
Connection connection = ConnectionFactory.CreateConnection??"BadTypeName"?? 1????
}
[Test]
[ExpectedException??typeof??ArgumentNullException????]
public void CreateConnectionThrowsWhenPassedNullType????
{
Connection connection = ConnectionFactory.CreateConnection??null?? 1????
}
[Test]
[ExpectedException??typeof??ArgumentException????]
public void CreateConnectionThrowsWhenPassedEmptyType????
{
Connection connection = ConnectionFactory.CreateConnection??String.Empty?? 1????
}
[Test]
[ExpectedException??typeof??ArgumentOutOfRangeException????]
public void CreateConnectionThrowsWhenPassedNegativePrice????
{
Connection connection = ConnectionFactory.CreateConnection??"WiredConnection"?? -1????
}
}
}
2. NUnit???????????MOCK???????????????????
??????????????????????Щ????????????????????????????????????????????????????XML?????????????????????
??????????????????????????????? ????Щ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????顣
???????и????????????????????????????д????????????????????????????????????????????????????????????λ????????????????????????????????????bug????????????к????????????????????????????????????????????????????????????????????????????С???????????????????????????????????????bug.
???????????MOCK?????????????????
???mock??????в?????????????????3?????裬??????
1. ??????????????????????
2. ?????????????????
3. ????????????mock???????????????
???????????ο???????????????????????????????????????????????????????????????????????????????????????????mock?????????????к???????????????????????Щ????????????????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????????д?ò??????????????????????????????Щ??????????????????????????????????????????????????????????????APP????????????????????????????????????????5??????????????????????SQL?????в??????????Щ???????裿??γ???????????????????????????????Щ???????????????????д?淶???????????????????????????????????????裿
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????