-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Syrx/2.3.0
Updates for 2.3.0
- Loading branch information
Showing
21 changed files
with
315 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Syrx.Commanders.Databases.Settings.Extensions.Json/UseFileExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Syrx.Extensions; | ||
using static Syrx.Validation.Contract; | ||
|
||
namespace Syrx.Commanders.Databases.Settings.Extensions.Json | ||
{ | ||
public static class UseFileExtensions | ||
{ | ||
public static SyrxBuilder UseFile(this SyrxBuilder factory, string fileName, IConfigurationBuilder builder) | ||
{ | ||
Throw<ArgumentNullException>(builder != null, $"ConfigurationBuilder is null! Check bootstrap."); | ||
Throw<ArgumentNullException>(!string.IsNullOrWhiteSpace(fileName), nameof(fileName)); | ||
|
||
builder?.AddJsonFile(fileName); | ||
|
||
return factory; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Syrx.Commanders.Databases.Settings.Extensions.Xml/UseFileExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Syrx.Extensions; | ||
using static Syrx.Validation.Contract; | ||
|
||
namespace Syrx.Commanders.Databases.Settings.Extensions.Xml | ||
{ | ||
public static class UseFileExtensions | ||
{ | ||
public static SyrxBuilder UseFile(this SyrxBuilder factory, string fileName, IConfigurationBuilder builder) | ||
{ | ||
Throw<ArgumentNullException>(builder != null, $"ConfigurationBuilder is null! Check bootstrap."); | ||
Throw<ArgumentNullException>(!string.IsNullOrWhiteSpace(fileName), nameof(fileName)); | ||
|
||
builder?.AddXmlFile(fileName); | ||
|
||
return factory; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 13 additions & 15 deletions
28
...x.Commanders.Databases.Settings.Readers/Syrx.Commanders.Databases.Settings.Readers.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>This package adds support for reading settings for Database Commanders from configuration sources.</Description> | ||
<PackageTags>syrx;data access;orm;micro-orm</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" /> | ||
<PackageReference Include="Syrx.Readers" Version="2.*" /> | ||
</ItemGroup> | ||
|
||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>This package adds support for reading settings for Database Commanders from configuration sources.</Description> | ||
<PackageTags>syrx;data access;orm;micro-orm</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syrx.Readers" Version="2.*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Syrx.Commanders.Databases.Settings\Syrx.Commanders.Databases.Settings.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...atabases.Connectors.Extensions.Tests.Unit/ServiceCollectionExtensionsTests/AddProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Moq; | ||
using Syrx.Commanders.Databases.Tests.Extensions; | ||
using System.Data.Common; | ||
using static Xunit.Assert; | ||
|
||
namespace Syrx.Commanders.Databases.Connectors.Extensions.Tests.Unit.ServiceCollectionExtensionsTests | ||
{ | ||
public class AddProvider | ||
{ | ||
private readonly IServiceCollection _services; | ||
|
||
public AddProvider() | ||
{ | ||
_services = new ServiceCollection(); | ||
} | ||
|
||
[Fact] | ||
public void NullProviderThrowsArgumentNullException() | ||
{ | ||
var result = Throws<ArgumentNullException>(() => _services.AddProvider(null)); | ||
result.HasMessage("The DbProviderFactory delegate cannot be null. (Parameter 'providerFactory')"); | ||
} | ||
|
||
[Fact] | ||
public void Successfully() | ||
{ | ||
var connection = new Mock<DbConnection>(); | ||
var dbProviderFactory = new Mock<DbProviderFactory>(); | ||
dbProviderFactory.Setup(x => x.CreateConnection()).Returns(connection.Object); | ||
|
||
Func<DbProviderFactory> factory = () => dbProviderFactory.Object; | ||
var result = _services.AddProvider(factory); | ||
|
||
var provider = _services.BuildServiceProvider(); | ||
var resolved = provider.GetService<Func<DbProviderFactory>>(); | ||
NotNull(resolved); | ||
Same(factory, resolved); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.