-
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.
Refactoring: MultiBankProviderFactory & MultiBankProviderBuilder.
- Loading branch information
o.nadymov
committed
Mar 29, 2024
1 parent
20de1b0
commit 9ae6a7d
Showing
19 changed files
with
364 additions
and
180 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
File renamed without changes
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,70 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<!-- Include symbols for debugging --> | ||
<PropertyGroup> | ||
<!-- This command creates external file (snupkg) with .pdb next to nuget file (nupkg) --> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
</PropertyGroup> | ||
|
||
<!-- https://github.com/dotnet/sourcelink --> | ||
<PropertyGroup> | ||
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) --> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
|
||
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB --> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
</PropertyGroup> | ||
|
||
<!-- Package info --> | ||
<PropertyGroup> | ||
<Product>Spoleto.VirtualKassa.MultiBank library</Product> | ||
<Authors>OlegNadymov;Spoleto-Software</Authors> | ||
<Company>SPOLETO Software Development</Company> | ||
<PackageIcon>MainIcon.jpg</PackageIcon> | ||
<PackageProjectUrl>https://spoleto.ru</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/spoleto-software/Spoleto.VirtualKassa.MultiBank</RepositoryUrl> | ||
<RepositoryType>GitHub</RepositoryType> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||
<PackageTags>МультиКасса; МультиБанк; ВиртуальнаяКасса; VirtualKassa; MultiBank; Multikassa</PackageTags> | ||
<Copyright>Copyright © $([System.DateTime]::Now.Year.ToString())</Copyright> | ||
<PackageReleaseNotes></PackageReleaseNotes> | ||
<Version>1.13.0</Version> | ||
<AssemblyVersion>1.13.0.0</AssemblyVersion> | ||
<FileVersion>1.13.0.0</FileVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<NoWarn>$(NoWarn);CS1591</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="$(MSBuildThisFileDirectory)..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
<Visible>False</Visible> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)..\README.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
<Visible>False</Visible> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)..\assets\MainIcon.jpg"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
<Visible>False</Visible> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/> | ||
</ItemGroup> | ||
|
||
</Project> |
24 changes: 24 additions & 0 deletions
24
src/Spoleto.VirtualKassa.MultiBank.Extensions/MultiBankProviderBuilder.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,24 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Spoleto.VirtualKassa.MultiBank.Extensions | ||
{ | ||
/// <summary> | ||
/// Spoleto.VirtualKassa.MultiBank dependency injection builder. | ||
/// </summary> | ||
public class MultiBankProviderBuilder | ||
{ | ||
/// <summary> | ||
/// Creates an instance of <see cref="MultiBankProviderBuilder"/>. | ||
/// </summary> | ||
/// <param name="serviceCollection">The services collection instance.</param> | ||
internal MultiBankProviderBuilder(IServiceCollection serviceCollection) | ||
{ | ||
ServiceCollection = serviceCollection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the service collection. | ||
/// </summary> | ||
public IServiceCollection ServiceCollection { get; } | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Spoleto.VirtualKassa.MultiBank.Extensions/ServiceCollectionExtensions.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,37 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Spoleto.VirtualKassa.MultiBank.Extensions | ||
{ | ||
/// <summary> | ||
/// Extension methods to configure an <see cref="IServiceCollection"/> for <see cref="IMultiBankProvider"/>. | ||
/// </summary> | ||
public static class ServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the Spoleto.VirtualKassa.MultiBank provider. | ||
/// </summary> | ||
/// <param name="serviceCollection">The service collection instance.</param> | ||
/// <returns>The <see cref="SmsServiceBuilder"/> instance is provided to support method chaining capabilities.</returns> | ||
public static MultiBankProviderBuilder AddMultiBank(this IServiceCollection serviceCollection) | ||
{ | ||
serviceCollection.AddHttpClient<IMultiBankProvider, MultiBankProvider>(); | ||
|
||
// registers the providers on this instance: | ||
return new MultiBankProviderBuilder(serviceCollection); | ||
} | ||
|
||
/// <summary> | ||
/// Adds the Spoleto.VirtualKassa.MultiBank provider with the specified instance of <see cref="HttpClient"/>. | ||
/// </summary> | ||
/// <param name="serviceCollection">The service collection instance.</param> | ||
/// <param name="httpClient">The <see cref="HttpClient"/> instance.</param> | ||
/// <returns>The <see cref="SmsServiceBuilder"/> instance is provided to support method chaining capabilities.</returns> | ||
public static MultiBankProviderBuilder AddMultiBank(this IServiceCollection serviceCollection, HttpClient httpClient) | ||
{ | ||
serviceCollection.AddTransient<IMultiBankProvider>(x => new MultiBankProvider(httpClient)); | ||
|
||
// registers the providers on this instance: | ||
return new MultiBankProviderBuilder(serviceCollection); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...poleto.VirtualKassa.MultiBank.Extensions/Spoleto.VirtualKassa.MultiBank.Extensions.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net7.0;net8.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<!-- Package info --> | ||
<PropertyGroup> | ||
<Title>Spoleto.VirtualKassa.MultiBank extensions for Microsoft DependencyInjection</Title> | ||
<PackageId>Spoleto.VirtualKassa.MultiBank.Extensions</PackageId> | ||
<PackageTags>МультиКасса; МультиБанк; ВиртуальнаяКасса; VirtualKassa; MultiBank; Multikassa</PackageTags> | ||
<Description> | ||
Расширения для работы с Microsoft Dependency injection фреймворком для C# SDK для интеграции с хостом Мульти-Банка (Узбекистан) для передачи информации об оплатах покупок. | ||
The extensions for Microsoft Dependency injection framework for the project for integration with MultiBank host. | ||
</Description> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Spoleto.VirtualKassa.MultiBank\Spoleto.VirtualKassa.MultiBank.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
33 changes: 33 additions & 0 deletions
33
src/Spoleto.VirtualKassa.MultiBank.Tests/MultiBankProviderFactoryTests.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,33 @@ | ||
namespace Spoleto.VirtualKassa.MultiBank.Tests | ||
{ | ||
public class MultiBankProviderFactoryTests | ||
{ | ||
[Test] | ||
public async Task CreateMultiBankProvider() | ||
{ | ||
// Arrange | ||
var factory = new MultiBankProviderFactory(); | ||
|
||
// Act | ||
var provider = factory.Build(); | ||
|
||
// Assert | ||
Assert.That(provider, Is.Not.Null); | ||
} | ||
|
||
[Test] | ||
public async Task CreateMultiBankProviderWithHttpClient() | ||
{ | ||
// Arrange | ||
var httpClient = new HttpClient(); | ||
var factory = new MultiBankProviderFactory() | ||
.WithHttpClient(httpClient); | ||
|
||
// Act | ||
var provider = factory.Build(); | ||
|
||
// Assert | ||
Assert.That(provider, Is.Not.Null); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.