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); }
} } |