Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring to prepare for async methods #198

Merged
merged 2 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Neo4j.Driver/Neo4j.Driver.Tests/Neo4j.Driver.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<Compile Include="Connector\PooledConnectionTests.cs" />
<Compile Include="Result\ResultReaderBuilderTests.cs" />
<Compile Include="Result\StatementResultReaderTests.cs" />
<Compile Include="Routing\RoutingTableManagerTests.cs" />
<Compile Include="TestUtil\NetworkExtensionsTests.cs" />
<Compile Include="Result\SummaryBuilderTests.cs" />
<Compile Include="RetryLogicTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
Expand All @@ -32,6 +33,23 @@ public class ClusterConnectionPoolTests
{
private static Uri ServerUri { get; } = new Uri("bolt+routing://1234:5678");

public class Constructor
{
[Fact]
public void ShouldEnsureInitialRouter()
{
var uris = new HashSet<Uri>{new Uri("bolt://123:456")};
var config = Config.DefaultConfig;
var connSettings = new ConnectionSettings(ServerUri, new Mock<IAuthToken>().Object, config);
var poolSettings = new ConnectionPoolSettings(config);

var pool = new ClusterConnectionPool(connSettings, poolSettings, uris, null);

pool.ToString().Should().Be(
"[{bolt://123:456/ : _availableConnections: {[]}, _inUseConnections: {[]}}]");
}
}

public class TryAcquireMethod
{
[Fact]
Expand Down
737 changes: 131 additions & 606 deletions Neo4j.Driver/Neo4j.Driver.Tests/Routing/LoadBalancerTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using FluentAssertions;
using Moq;
using Neo4j.Driver.Internal;
using Neo4j.Driver.Internal.Routing;
using Neo4j.Driver.V1;
using Xunit;
Expand All @@ -36,6 +39,23 @@ private static IEnumerable<Uri> CreateUriArray(int count)
return uris;
}

public class Constructor
{
[Fact]
public void ShouldEnsureInitialRouter()
{
var initUri = new Uri("bolt://123:456");
var routers = new HashSet<Uri>{initUri};
var table = new RoundRobinRoutingTable(routers);

Uri uri;
table.TryNextRouter(out uri).Should().BeTrue();
uri.Should().Be(initUri);

table.All().Single().Should().Be(initUri);
}
}

public class IsStatleMethod
{
[Theory] [InlineData(1, 2, 1, 5 * 60, false)] // 1 router, 2 reader, 1 writer
Expand All @@ -49,7 +69,6 @@ public void ShouldBeStaleInReadModeIfOnlyHaveOneRouter(int routerCount, int read
CreateUriArray(routerCount),
CreateUriArray(readerCount),
CreateUriArray(writerCount),
new Stopwatch(),
expireAfterSeconds);
table.IsStale(AccessMode.Read).Should().Be(isStale);
}
Expand All @@ -66,7 +85,6 @@ public void ShouldBeStaleInWriteModeIfOnlyHaveOneRouter(int routerCount, int rea
CreateUriArray(routerCount),
CreateUriArray(readerCount),
CreateUriArray(writerCount),
new Stopwatch(),
expireAfterSeconds);
table.IsStale(AccessMode.Write).Should().Be(isStale);
}
Expand All @@ -82,7 +100,7 @@ public void ShouldInjectInFront()
CreateUriArray(3),
CreateUriArray(0),
CreateUriArray(0),
new Stopwatch(), 5 * 60);
5 * 60);
Uri router;
table.TryNextRouter(out router);
var head = new Uri("http://neo4j:10");
Expand All @@ -102,6 +120,5 @@ public void ShouldInjectInFront()
router.Should().Be(head);
}
}

}
}
Loading