public WhenCreatingAnOpenedConnectionWithAHostName() { _connectionFactory = new Mock <IConnectionFactory>(); _connection = new Mock <IOpenableConnection>(); _connectionFactory .Setup(cf => cf.Create(It.IsAny <IPEndPoint>())) .Returns(_connection.Object); _connectionOpener = new ConnectionCreator(_connectionFactory.Object); _connectionOpener.CreateOpenedAsync("localhost", 1234, CancellationToken.None).Wait(); }
public async Task ThenAnExceptionIsThrown() { var ex = await Assert.ThrowsAsync <ConnectionException>(() => _connectionOpener.CreateOpenedAsync("localhost", 70000, CancellationToken.None)); Assert.Equal("Port 70000 outside of the range 0 to 65535", ex.Message); }
public async Task ThenAnExceptionIsThrown() { var ex = await Assert.ThrowsAsync <ConnectionException>(() => _connectionOpener.CreateOpenedAsync("invalid.host.name.", 1234, CancellationToken.None)); Assert.Equal("Unable to resolve host 'invalid.host.name.'", ex.Message); }