Skip to content

Commit

Permalink
unit tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid committed Jan 19, 2024
1 parent 0249695 commit c7c30a0
Show file tree
Hide file tree
Showing 8 changed files with 441 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 01-Core/Jinget.Core.DiScanner/Jinget.Core.DiScanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Title>Jinget Core</Title>
<PackageProjectUrl>https://github.com/VahidFarahmandian/Jinget</PackageProjectUrl>
<PackageTags>jinget, di, dependency injection, asp.net core, .net core, .net</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -30,4 +31,11 @@
</None>
</ItemGroup>

<ItemGroup>
<None Update="README.md">
<PackagePath>\</PackagePath>
<Pack>True</Pack>
</None>
</ItemGroup>

</Project>
74 changes: 74 additions & 0 deletions 01-Core/Jinget.Core.DiScanner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Jinget.Core.DiScanner
Using this library, you can easily register your source code dependencies automatically without the need to write repetitive and annoying codes.


## How to Use:

Download the package from NuGet using Package Manager:
`Install-Package Jinget.Core.DiScanner`
You can also use other methods supported by NuGet. Check [Here](https://www.nuget.org/packages/Jinget.Core.DiScanner"Here") for more information.

## Samples

***FromCallingAssembly:***

Will scan for types from the calling assembly.

```csharp
_services.Scan(
s => s.FromCallingAssembly()
.AddClasses()
.AsImplementedInterfaces()
.WithTransientLifetime());
```

The above code will scan the calling assembly and registers each matching concrete type as all of its implemented interfaces. `WithTransientLifetime` indicates that the services should have `Transient` lifetime.

***FromExecutingAssembly:***

Will scan for types from the calling assembly.

```csharp
_services.Scan(
s => s.FromExecutingAssembly()
.AddClasses()
.AsImplementedInterfaces()
.WithTransientLifetime());
```

The above code will scan for types from the currently executing assembly, and registers each matching concrete type as all of its implemented interfaces.

***FromAssembliesOf:***

```csharp
_services.Scan(
s => s.FromAssembliesOf(typeof(Sample))
.AddClasses()
.AsSelfWithInterfaces()
.WithSingletonLifetime());
```

The above code will scan the assembly containing the `Sample` type and registers each matching concrete type as all of its implemented interfaces, by returning an instance of the main type

***FromAssemblies:***

```csharp
_services.Scan(
s => s.FromAssemblies(typeof(ICustomInterface).Assembly, typeof(ISelector).Assembly)
.AddClasses()
.AsImplementedInterfaces()
.WithTransientLifetime());
```

The above code will scan for types in each assembly in assemblies, and registers each matching concrete type as all of its implemented interfaces, by returning an instance of the main type

------------
## How to install
In order to install Jinget.Core.DiScanner please refer to [nuget.org](https://www.nuget.org/packages/Jinget.Core.DiScanner "nuget.org")

## Contact Me
👨‍💻 Twitter: https://twitter.com/_jinget

📧 Email: [email protected]

📣 Instagram: https://www.instagram.com/vahidfarahmandian
7 changes: 7 additions & 0 deletions Jinget.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jinget.Blazor.Test", "Tests
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jinget.Core.DiScanner", "01-Core\Jinget.Core.DiScanner\Jinget.Core.DiScanner.csproj", "{9411D2C7-AF8E-4C8A-A11E-DA52E3BEB6C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jinget.Core.DiScanner.Tests", "Tests\Jinget.Core.DiScanner.Tests\Jinget.Core.DiScanner.Tests.csproj", "{F464F7DD-38F2-412C-9CD1-28D53853BFE8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -78,6 +80,10 @@ Global
{9411D2C7-AF8E-4C8A-A11E-DA52E3BEB6C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9411D2C7-AF8E-4C8A-A11E-DA52E3BEB6C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9411D2C7-AF8E-4C8A-A11E-DA52E3BEB6C9}.Release|Any CPU.Build.0 = Release|Any CPU
{F464F7DD-38F2-412C-9CD1-28D53853BFE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F464F7DD-38F2-412C-9CD1-28D53853BFE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F464F7DD-38F2-412C-9CD1-28D53853BFE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F464F7DD-38F2-412C-9CD1-28D53853BFE8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -92,6 +98,7 @@ Global
{A3E2F74D-AEB2-4D7A-8B75-F8198BF5FBE0} = {18874D4F-0257-4DF2-A97F-F532A36BAD0E}
{4BFE23D5-F786-4349-9481-A7D4A884CBEC} = {F1B06C67-988D-4E24-8110-92C9B6D4CBC0}
{9411D2C7-AF8E-4C8A-A11E-DA52E3BEB6C9} = {115DD383-ACB4-48AA-A6C2-C6105314F051}
{F464F7DD-38F2-412C-9CD1-28D53853BFE8} = {F1B06C67-988D-4E24-8110-92C9B6D4CBC0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8690B4B4-1E8A-4C1D-9A63-123EAD0492EE}
Expand Down
Loading

0 comments on commit c7c30a0

Please sign in to comment.