Browse files

Issue 54 - Specify timeout when default port is being used.

Also added unit tests.
  • Loading branch information...
1 parent dc74549 commit 4207b271ed14d3afd1b603211fe060ee17aad956 @dlbromen dlbromen committed Sep 11, 2012
View
2 src/Connections/ConnectionBuilder.cs
@@ -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));
}
}
View
57 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);
+ }
+ }
+ }
+}
View
1 test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
@@ -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" />

0 comments on commit 4207b27

Please sign in to comment.