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

some minor cleanup #3

Merged
merged 1 commit into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ await collection.FindAsync(Builders<BsonDocument>.Filter.Eq("_id", "blah"),
new FindOptions<BsonDocument, BsonDocument>());

await Verifier.Verify("collection");

```

Will result in the following verified file:
Expand Down
16 changes: 5 additions & 11 deletions Verify.MongoDB.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using MongoDB.Bson;
using MongoDB.Driver;
using VerifyTests;
using VerifyXunit;
using Xunit;

namespace Verify.MongoDB.Tests;

Expand All @@ -22,7 +17,7 @@ public async Task FindAsync()
{
var configuration = GetConfiguration();

var clientSettings = MongoClientSettings.FromUrl(new MongoUrl(configuration["MongoConnectionString"]));
var clientSettings = MongoClientSettings.FromUrl(new(configuration["MongoConnectionString"]));

clientSettings.EnableRecording();

Expand All @@ -38,7 +33,7 @@ public async Task FindAsync()

await collection.FindAsync(Builders<BsonDocument>.Filter.Eq("_id", "blah"),
new FindOptions<BsonDocument, BsonDocument>());

await Verifier.Verify("collection");
}

Expand All @@ -47,7 +42,7 @@ public async Task InsertOneAsync()
{
var configuration = GetConfiguration();

var clientSettings = MongoClientSettings.FromUrl(new MongoUrl(configuration["MongoConnectionString"]));
var clientSettings = MongoClientSettings.FromUrl(new(configuration["MongoConnectionString"]));

clientSettings.EnableRecording();

Expand All @@ -61,7 +56,7 @@ public async Task InsertOneAsync()

MongoDBRecording.StartRecording();

await collection.InsertOneAsync(new BsonDocument()
await collection.InsertOneAsync(new()
{
{"_id", "C2E1B774-A997-4818-B104-E915F7DCA9C1"}
});
Expand All @@ -71,10 +66,9 @@ await collection.InsertOneAsync(new BsonDocument()

private static IConfigurationRoot GetConfiguration()
{
var configuration = new ConfigurationBuilder()
return new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("local.settings.json", false)
.Build();
return configuration;
}
}
5 changes: 0 additions & 5 deletions Verify.MongoDB.Tests/Verify.MongoDB.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down Expand Up @@ -36,9 +34,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
<None Update="IntegrationTests.Test1.verified.txt">
<DependentUpon>IntegrationTests.cs</DependentUpon>
</None>
</ItemGroup>

<Target Name="CreateLocalSettingsJson" Inputs="local.settings.template.json" Outputs="local.settings.json" Condition="!exists('local.settings.json')" BeforeTargets="BeforeBuild;Restore">
Expand Down
2 changes: 1 addition & 1 deletion Verify.MongoDB/LogCommandInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class LogCommandInterceptor

public static void Start()
{
asyncLocal.Value = new State();
asyncLocal.Value = new();
}

public static IEnumerable<LogEntryBase>? Stop()
Expand Down
2 changes: 1 addition & 1 deletion Verify.MongoDB/MongoDBRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public static IEnumerable<LogEntryBase> FinishRecording()
{
return entries;
}
throw new Exception("No recorded state. It is possible `MongoRecording.StartRecording()` has not been called on the MongoClient.");
throw new("No recorded state. It is possible `MongoRecording.StartRecording()` has not been called on the MongoClient.");
}
}
7 changes: 2 additions & 5 deletions Verify.MongoDB/Verify.MongoDB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<LangVersion>10</LangVersion>
<RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.5.0" />
<PackageReference Include="Verify" Version="14.7.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />
Expand Down