Skip to content

Fluent assertions lock 7.0 #836

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

Open
wants to merge 7 commits into
base: 5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ItemGroup>
<Content Include="App.config" />
<PackageReference Include="Castle.Core" Version="5.1.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions" Version="[7.0.0]" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Moq" Version="4.20.69" />
Expand Down
7 changes: 4 additions & 3 deletions Neo4j.Driver/Neo4j.Driver.Tests/AsyncSessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ internal static Mock<IConnection> MockedConnectionWithSuccessResponse(IBoltProto
It.IsAny<IRequestMessage>(),
It.IsAny<IResponseHandler>()))
.Returns(Task.CompletedTask)
.Callback(
(IRequestMessage _, IResponseHandler h1) => { h1.OnSuccess(new Dictionary<string, object>()); });
.Callback((IRequestMessage _, IResponseHandler h1) => { h1.OnSuccess(new Dictionary<string, object>()); });

if (protocol == null)
{
Expand Down Expand Up @@ -299,7 +298,9 @@ public async void PipelinedShouldBeginWithoutBlocking()
false,
false);

await session.PipelinedExecuteReadAsync(_ => Task.FromResult(null as EagerResult<IRecord[]>), new TransactionConfig());
await session.PipelinedExecuteReadAsync(
_ => Task.FromResult(null as EagerResult<IRecord[]>),
new TransactionConfig());

mockProtocol.Verify(
x =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Copyright (c) "Neo4j"
// Neo4j Sweden AB [http://neo4j.com]
//
// This file is part of Neo4j.
//
// Neo4j Sweden AB [https://neo4j.com]
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -44,7 +42,8 @@ public async Task ShouldCacheToken()
{
var (authData, _) = GetTwoAuthTokens();

int callCount = 0;
var callCount = 0;

ValueTask<AuthTokenAndExpiration> TokenProvider()
{
callCount++;
Expand Down
2 changes: 1 addition & 1 deletion Neo4j.Driver/Neo4j.Driver.Tests/BookmarkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ public void ShouldUnionValues(string[] values1, string[] values2, string[] value
}
}
}
}
}
4 changes: 2 additions & 2 deletions Neo4j.Driver/Neo4j.Driver.Tests/ConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public void WithNotifications_ShouldWorkWithSecondParameterNull()
var configBuilder = new ConfigBuilder(new Config());

// this line would fail to compile before the fix
configBuilder.WithNotifications(Severity.Warning, null);
configBuilder.WithNotifications(Severity.Warning);

var config = configBuilder.Build()
.NotificationsConfig.Should()
Expand Down Expand Up @@ -451,7 +451,7 @@ public void WithNotifications_ShouldHaveNullExclusions()
var configBuilder = new ConfigBuilder(new Config());

// this line would fail to compile before the fix
configBuilder.WithNotifications(Severity.Warning, null);
configBuilder.WithNotifications(Severity.Warning);

var config = configBuilder.Build()
.NotificationsConfig.Should()
Expand Down
3 changes: 2 additions & 1 deletion Neo4j.Driver/Neo4j.Driver.Tests/ConnectionPoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
using Moq;
using Neo4j.Driver.Internal;
using Neo4j.Driver.Internal.Connector;
using Neo4j.Driver.Internal.Util;
using Neo4j.Driver.Internal.Protocol;
using Neo4j.Driver.Internal.Util;
using Neo4j.Driver.Tests.TestUtil;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -291,6 +291,7 @@ private Mock<IConnectionValidator> MockValidator(Action<Mock<IConnectionValidato
validator.Setup(x => x.GetConnectionLifetimeStatus(It.IsAny<IPooledConnection>()))
.Returns(AcquireStatus.Healthy);
}

return validator;
}

Expand Down
34 changes: 18 additions & 16 deletions Neo4j.Driver/Neo4j.Driver.Tests/ConnectionValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,23 @@ private static ConnectionValidator NewConnectionValidator(
TimeSpan? maxConnLifetime = null,
TimeSpan? livelinessCheckTimeout = null)
{
return new ConnectionValidator(connIdleTimeout ?? Config.InfiniteInterval,
maxConnLifetime ?? Config.InfiniteInterval, livelinessCheckTimeout);
return new ConnectionValidator(
connIdleTimeout ?? Config.InfiniteInterval,
maxConnLifetime ?? Config.InfiniteInterval,
livelinessCheckTimeout);
}

private static (Mock<IPooledConnection> conn, Mock<ITimer> idle, Mock<ITimer> life) Mock()
{
var conn = new Mock<IPooledConnection>();
conn.Setup(x => x.Version).Returns(BoltProtocolVersion.V5_1);

var idleTimer = new Mock<ITimer>();
var lifeTimer = new Mock<ITimer>();

conn.Setup(x => x.IdleTimer).Returns(idleTimer.Object);
conn.Setup(x => x.LifetimeTimer).Returns(lifeTimer.Object);
return (conn, idleTimer, lifeTimer);
}

public class IsConnectionReusableTests
Expand Down Expand Up @@ -131,17 +146,4 @@ public void ShouldRequireLiveness()
idleTimer.Verify(x => x.Reset(), Times.Once);
}
}

private static (Mock<IPooledConnection> conn, Mock<ITimer> idle, Mock<ITimer> life) Mock()
{
var conn = new Mock<IPooledConnection>();
conn.Setup(x => x.Version).Returns(BoltProtocolVersion.V5_1);

var idleTimer = new Mock<ITimer>();
var lifeTimer = new Mock<ITimer>();

conn.Setup(x => x.IdleTimer).Returns(idleTimer.Object);
conn.Setup(x => x.LifetimeTimer).Returns(lifeTimer.Object);
return (conn, idleTimer, lifeTimer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ internal static SuccessMessage SuccessMessage(IDictionary<string, object> fields
? new SuccessMessage(new Dictionary<string, object>())
: new SuccessMessage(fields);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private static (Mock<ITcpSocketClient>, Mock<IConnectionIoFactory>) CreateMockIo
mockIoFactory
.Setup(x => x.TcpSocketClient(It.IsAny<DriverContext>(), It.IsAny<ILogger>()))
.Returns(connMock.Object);

configureFactory?.Invoke(mockIoFactory);

return (connMock, mockIoFactory);
Expand Down Expand Up @@ -127,8 +127,7 @@ public async void ShouldNotCatchHandshakeFailuresOrConstructIoTypes()

var client = NewClient(io, null, mockHandshaker);

var ex = await Record.ExceptionAsync(
() => client.ConnectAsync(CancellationToken.None));
var ex = await Record.ExceptionAsync(() => client.ConnectAsync(CancellationToken.None));

mockHandshaker.Verify(
x => x.DoHandshakeAsync(
Expand Down Expand Up @@ -337,4 +336,4 @@ public async Task ShouldCallDisconnectAsyncOnTheTcpSocketClientWhenStoppedAsync(
client.IsOpen.Should().BeFalse();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ public async Task ShouldConnectClient()
var bpFactory = new Mock<IBoltProtocolFactory>();
bpFactory.Setup(x => x.ForVersion(BoltProtocolVersion.V3_0)).Returns(protocolMock.Object);

var conn = NewSocketConnection(mockClient.Object, boltProtocolFactory: bpFactory.Object,
var conn = NewSocketConnection(
mockClient.Object,
boltProtocolFactory: bpFactory.Object,
context: new DriverContext(new Uri("bolt://localhost:7687"), AuthTokenManagers.None, new Config()));

// When
await conn.InitAsync(null);
await conn.InitAsync();

// Then
mockClient.Verify(c => c.ConnectAsync(CancellationToken.None), Times.Once);
Expand All @@ -102,7 +104,7 @@ public async Task ShouldThrowClientErrorIfFailedToConnectToServerWithinTimeout()
// ReSharper disable once ObjectCreationAsStatement
var conn = new SocketConnection(mockClient.Object, AuthToken, Logger, Server);
// When
var error = await Record.ExceptionAsync(() => conn.InitAsync(null));
var error = await Record.ExceptionAsync(() => conn.InitAsync());
// Then
error.Should().BeOfType<IOException>();
error.Message.Should().Be("I will stop socket conn from initialization");
Expand Down Expand Up @@ -227,7 +229,7 @@ public async Task ShouldEnqueueBoth()
var h1 = new Mock<IResponseHandler>();
var m2 = new Mock<IRequestMessage>();
var h2 = new Mock<IResponseHandler>();

await con.EnqueueAsync(m1.Object, h1.Object, m2.Object, h2.Object);

con.Messages[0].Should().Be(m1.Object);
Expand Down
19 changes: 12 additions & 7 deletions Neo4j.Driver/Neo4j.Driver.Tests/DriverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using Moq;
using Neo4j.Driver.Internal;
using Xunit;

using InternalDriver = Neo4j.Driver.Internal.Driver;

#pragma warning disable CS0618
Expand Down Expand Up @@ -71,8 +70,7 @@ public void ShouldErrorIfUriWrongFormat()
[Fact]
public void ShouldErrorIfBoltSchemeWithRoutingContext()
{
var exception = Record.Exception(
() => GraphDatabase.Driver("bolt://localhost/?name=molly&age=1&color=white"));
var exception = Record.Exception(() => GraphDatabase.Driver("bolt://localhost/?name=molly&age=1&color=white"));

exception.Should().BeOfType<ArgumentException>();
exception.Message.Should().Contain("Routing context are not supported with scheme 'bolt'");
Expand Down Expand Up @@ -156,10 +154,12 @@ public async void ShouldTryVerifyConnection()
mock.Setup(x => x.VerifyConnectivityAndGetInfoAsync())
.Returns(Task.FromResult(new Mock<IServerInfo>().Object));

var driver = (IDriver)new InternalDriver(new Uri("bolt://localhost"),
var driver = (IDriver)new InternalDriver(
new Uri("bolt://localhost"),
mock.Object,
null,
TestDriverContext.MockContext);

var connects = await driver.TryVerifyConnectivityAsync();

connects.Should().BeTrue();
Expand All @@ -172,10 +172,12 @@ public async void ShouldCatchInTryVerifyConnection()
mock.Setup(x => x.VerifyConnectivityAndGetInfoAsync())
.ThrowsAsync(new Exception("broken"));

var driver = (IDriver)new InternalDriver(new Uri("bolt://localhost"),
var driver = (IDriver)new InternalDriver(
new Uri("bolt://localhost"),
mock.Object,
null,
TestDriverContext.MockContext);

var connects = await driver.TryVerifyConnectivityAsync();

connects.Should().BeFalse();
Expand All @@ -189,7 +191,8 @@ public async void ShouldGetInfoConnection()
mock.Setup(x => x.VerifyConnectivityAndGetInfoAsync())
.Returns(Task.FromResult(mockServerInfo));

var driver = new InternalDriver(new Uri("bolt://localhost"),
var driver = new InternalDriver(
new Uri("bolt://localhost"),
mock.Object,
null,
TestDriverContext.MockContext);
Expand All @@ -205,10 +208,12 @@ public async void ShouldTestSupportMultiDb()
{
var mock = new Mock<IConnectionProvider>();
mock.Setup(x => x.SupportsMultiDbAsync()).Returns(Task.FromResult(true));
var driver = new InternalDriver(new Uri("bolt://localhost"),
var driver = new InternalDriver(
new Uri("bolt://localhost"),
mock.Object,
null,
TestDriverContext.MockContext);

await driver.SupportsMultiDbAsync();

mock.Verify(x => x.SupportsMultiDbAsync(), Times.Once);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// Copyright (c) "Neo4j"
// Neo4j Sweden AB [http://neo4j.com]
//
// This file is part of Neo4j.
//
// Licensed under the Apache License, Version 2.0 (the "License"):
// you may not use this file except in compliance with the License.
// Neo4j Sweden AB [https://neo4j.com]
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using FluentAssertions;
using Neo4j.Driver.Internal.ExceptionHandling;
Expand Down Expand Up @@ -46,7 +43,8 @@ public class Neo4jExceptionFactoryTests
["Neo.TransientError.TemporaryDisabled", typeof(TransientException)]
];

[Theory, MemberData(nameof(CodeToTypeMapping))]
[Theory]
[MemberData(nameof(CodeToTypeMapping))]
public void ShouldCreateCorrectExceptionType(string code, Type exceptionType)
{
var subject = new Neo4jExceptionFactory();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Copyright (c) "Neo4j"
// Neo4j Sweden AB [http://neo4j.com]
//
// This file is part of Neo4j.
//
// Neo4j Sweden AB [https://neo4j.com]
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -275,7 +273,7 @@ public async Task ShouldReturnMappedTransformedReducedValue()

var result = await subject
.WithMap(i => i * 10)
.WithReduce(() => 0, (x, y) => x + y, i => $"<{(i * 2)}>")
.WithReduce(() => 0, (x, y) => x + y, i => $"<{i * 2}>")
.ExecuteAsync();

result.Result.Should().Be("<900>");
Expand Down Expand Up @@ -352,7 +350,7 @@ public async Task ShouldUseStreamProcessor()

async IAsyncEnumerable<int> GetInts(int start, int count)
{
foreach(var i in Enumerable.Range(start, count))
foreach (var i in Enumerable.Range(start, count))
{
await Task.Yield();
yield return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ void Callback(Memory<byte> _, CancellationToken token)

const int timeout = 100;

var ex = await Record.ExceptionAsync(
() => streamMock.Object.ReadWithTimeoutAsync(new byte[1], 0, 1, timeout));
var ex = await Record.ExceptionAsync(() => streamMock.Object.ReadWithTimeoutAsync(new byte[1], 0, 1, timeout));

ex.Should()
.BeOfType<ConnectionReadTimeoutException>()
Expand Down
2 changes: 1 addition & 1 deletion Neo4j.Driver/Neo4j.Driver.Tests/Filters/OSFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ public class UnixTheoryAttribute : OSTheoryAttribute
public UnixTheoryAttribute() : base(OSPlatform.Linux, OSPlatform.OSX)
{
}
}
}
2 changes: 1 addition & 1 deletion Neo4j.Driver/Neo4j.Driver.Tests/Filters/RuntimeFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ public DotnetCoreTheoryAttribute()
Skip = "Test is supposed to be run only on .net core runtimes";
}
}
}
}
Loading