???????????????????
???????????? ???????[ 2011/9/14 13:45:18 ] ????????
????????????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);
}
}
}
??????
???·???
??????????????????
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