Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Issue 54 - Specify timeout when default port is being used.
Also added unit tests.
  • Loading branch information
dlbromen committed Sep 12, 2012
1 parent dc74549 commit 4207b27
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Connections/ConnectionBuilder.cs
Expand Up @@ -341,7 +341,7 @@ private void InitializeConnectionString(string connectionString)
Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
}
else
Servers.Add(new Server(host));
Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
}
}

Expand Down
57 changes: 57 additions & 0 deletions test/FluentCassandra.Tests/Bugs/Issue65ServerTimeoutLost.cs
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using FluentCassandra.Connections;

namespace FluentCassandra.Bugs
{
public class Issue65ServerTimeoutLost
{
[Fact]
public void TestSingleServerWithHostAndPort()
{
Assert.Equal(5, new ConnectionBuilder("Server=host:123;Connection Timeout=5").Servers[0].Timeout);
}

[Fact]
public void TestSingleServerWithHostAndDefaultPort()
{
Assert.Equal(5, new ConnectionBuilder("Server=host;Connection Timeout=5").Servers[0].Timeout);
}

[Fact]
public void TestMultipleServersWithHostAndPort()
{
var servers = new ConnectionBuilder("Server=host:123,host2:456,host3:789;Connection Timeout=5").Servers;
Assert.Equal(3, servers.Count);
foreach (var server in servers)
{
Assert.Equal(5, server.Timeout);
}
}

[Fact]
public void TestMultipleServersWithHostAndDefaultPort()
{
var servers = new ConnectionBuilder("Server=host,host2,host3;Connection Timeout=5").Servers;
Assert.Equal(3, servers.Count);
foreach (var server in servers)
{
Assert.Equal(5, server.Timeout);
}
}

[Fact]
public void TestMultipleServersWithHostAndMixedPorts()
{
var servers = new ConnectionBuilder("Server=host:123,host2,host3:789;Connection Timeout=5").Servers;
Assert.Equal(3, servers.Count);
foreach (var server in servers)
{
Assert.Equal(5, server.Timeout);
}
}
}
}
1 change: 1 addition & 0 deletions test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
Expand Up @@ -56,6 +56,7 @@
<Compile Include="Bugs\Issue25JavaBigDecimalBinaryConversion.cs" />
<Compile Include="Bugs\Issue36KeyAliasSupport.cs" />
<Compile Include="Bugs\Issue39CompositeTypeAsKey.cs" />
<Compile Include="Bugs\Issue65ServerTimeoutLost.cs" />
<Compile Include="CassandraDatabaseSetupFixture.cs" />
<Compile Include="CassandraQueryTest.cs" />
<Compile Include="Connections\ConnectionProviderTests.cs" />
Expand Down

0 comments on commit 4207b27

Please sign in to comment.