Skip to content

Commit

Permalink
add new builder extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ershad95 committed Jun 6, 2024
1 parent 18e68d9 commit 5ef3bde
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 1,817 deletions.
18 changes: 15 additions & 3 deletions ServiceCollector.Fake/IServiceConfigExtension.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System;
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using AutoFixture.Dsl;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using NSubstitute;
using ServiceCollector.Abstractions;

namespace ServiceCollector.Fake
{
public class Dto
{
public int Age { get; set; }
}

public static partial class ServiceConfigExtension
{
Expand All @@ -28,7 +34,6 @@ public static IServiceConfig Fake<TService>(
string targetEnvironment = "Development")
where TService : class
{

if (action is null)
return serviceConfig;

Expand All @@ -45,7 +50,6 @@ public static IServiceConfig Fake<TService>(
return serviceConfig;
}


public static IServiceConfig FakeInMultiEnvironments<TService>(
this IServiceConfig serviceConfig,
Action<FakeConfigurationWithMultiEnvironment<TService>> action,
Expand All @@ -56,7 +60,7 @@ public static IServiceConfig FakeInMultiEnvironments<TService>(
action(fakeConfiguration);

var service = fakeConfiguration.Services[currentEnvironment];
if (service !=null)
if (service != null)
{
serviceConfig
.ServiceCollection
Expand All @@ -65,5 +69,13 @@ public static IServiceConfig FakeInMultiEnvironments<TService>(

return serviceConfig;
}

public static void ResultBuilder<TObject>(
this TObject result,
Action<TObject> action)
where TObject : class
{
action(result);
}
}
}
18 changes: 12 additions & 6 deletions ServiceCollector.Fake/ServiceCollector.Fake.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<PropertyGroup>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>ServiceCollector.Fake</Title>
<Authors>Ershad Raoufi</Authors>
<PackageIcon>icon.png</PackageIcon>
<TargetFramework>net6.0</TargetFramework>
<Description>you can fake your services without create any classes just read document and enjoy it :)</Description>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,12 +19,16 @@
<ItemGroup>
<ProjectReference Include="..\ServiceCollector.Abstractions\ServiceCollector.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Update="icon.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>


<PropertyGroup>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
</Project>
Binary file not shown.
Binary file modified ServiceCollector.Fake/bin/Release/net6.0/ServiceCollector.Fake.dll
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
<version>1.0.0</version>
<title>ServiceCollector.Fake</title>
<authors>Ershad Raoufi</authors>
<description>Package Description</description>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<icon>icon.png</icon>
<description>you can fake your services without create any classes just read document and enjoy it :)</description>
<dependencies>
<group targetFramework="net6.0">
<dependency id="ServiceCollector.Abstractions" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="AutoFixture" version="4.18.1" exclude="Build,Analyzers" />
<dependency id="AutoFixture.AutoNSubstitute" version="4.18.1" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.1">
<dependency id="ServiceCollector.Abstractions" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="AutoFixture" version="4.18.1" exclude="Build,Analyzers" />
<dependency id="AutoFixture.AutoNSubstitute" version="4.18.1" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="C:\Users\Ershad\RiderProjects\ServiceCollector\ServiceCollector.Fake\bin\Release\net6.0\ServiceCollector.Fake.dll" target="lib\net6.0\ServiceCollector.Fake.dll" />
<file src="C:\Users\Ershad\RiderProjects\ServiceCollector\ServiceCollector.Fake\bin\Release\netstandard2.1\ServiceCollector.Fake.dll" target="lib\netstandard2.1\ServiceCollector.Fake.dll" />
<file src="C:\Users\Ershad\RiderProjects\ServiceCollector\ServiceCollector.Fake\icon.png" target="icon.png" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

[assembly: System.Reflection.AssemblyCompanyAttribute("Ershad Raoufi")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("you can fake your services without create any classes just read document and enjo" +
"y it :)")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("ServiceCollector.Fake")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b3b9bc822b47d3b3a92b3096a68fcd5a910df112
1a81661de4a00be58e6fe78c0f2451cd4850907e
Binary file modified ServiceCollector.Fake/obj/Release/net6.0/ServiceCollector.Fake.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,12 @@
"packagesPath": "C:\\Users\\Ershad\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Ershad\\RiderProjects\\ServiceCollector\\ServiceCollector.Fake\\obj\\",
"projectStyle": "PackageReference",
"crossTargeting": true,
"configFilePaths": [
"C:\\Users\\Ershad\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0",
"netstandard2.1"
"net6.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
Expand All @@ -141,14 +139,6 @@
"projectPath": "C:\\Users\\Ershad\\RiderProjects\\ServiceCollector\\ServiceCollector.Abstractions\\ServiceCollector.Abstractions.csproj"
}
}
},
"netstandard2.1": {
"targetAlias": "netstandard2.1",
"projectReferences": {
"C:\\Users\\Ershad\\RiderProjects\\ServiceCollector\\ServiceCollector.Abstractions\\ServiceCollector.Abstractions.csproj": {
"projectPath": "C:\\Users\\Ershad\\RiderProjects\\ServiceCollector\\ServiceCollector.Abstractions\\ServiceCollector.Abstractions.csproj"
}
}
}
},
"warningProperties": {
Expand Down Expand Up @@ -201,36 +191,6 @@
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.305\\RuntimeIdentifierGraph.json"
},
"netstandard2.1": {
"targetAlias": "netstandard2.1",
"dependencies": {
"AutoFixture": {
"target": "Package",
"version": "[4.18.1, )"
},
"AutoFixture.AutoNSubstitute": {
"target": "Package",
"version": "[4.18.1, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"NETStandard.Library": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.305\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
Loading

0 comments on commit 5ef3bde

Please sign in to comment.