-
Notifications
You must be signed in to change notification settings - Fork 6
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 #189 from cihandeniz/issue/auto-find-entry-assembly
Issue / Auto Find Entry Assembly
- Loading branch information
Showing
8 changed files
with
49 additions
and
13 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
13 changes: 8 additions & 5 deletions
13
src/recipe/Baked.Recipe.Service.Application/Core/Dotnet/DotnetCoreFeature.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 |
---|---|---|
@@ -1,24 +1,27 @@ | ||
using Baked.Architecture; | ||
using Baked.Testing; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.FileProviders; | ||
using System.Reflection; | ||
|
||
namespace Baked.Core.Dotnet; | ||
|
||
public class DotnetCoreFeature(Assembly _entryAssembly, Func<Assembly, string?> _baseNamespace) | ||
public class DotnetCoreFeature(Assembly? _entryAssembly, Func<Assembly, string?> _baseNamespace) | ||
: IFeature<CoreConfigurator> | ||
{ | ||
public void Configure(LayerConfigurator configurator) | ||
{ | ||
configurator.ConfigureServiceCollection(services => | ||
{ | ||
var entryAssembly = _entryAssembly | ||
?? (configurator.IsNfr() ? Nfr.EntryAssembly : Assembly.GetEntryAssembly()) | ||
?? throw new("'EntryAssembly' should have existed"); | ||
services.AddSingleton(TimeProvider.System); | ||
services.AddSingleton<ITextTransformer, HumanizerTextTransformer>(); | ||
services.AddFileProvider(new EmbeddedFileProvider(_entryAssembly, _baseNamespace(_entryAssembly))); | ||
services.AddFileProvider(new PhysicalFileProvider(Path.GetDirectoryName(_entryAssembly.Location) ?? | ||
throw new("'EntryAssembly' should have a not null location")) | ||
); | ||
services.AddFileProvider(new EmbeddedFileProvider(entryAssembly, _baseNamespace(entryAssembly))); | ||
services.AddFileProvider(new PhysicalFileProvider(Path.GetDirectoryName(entryAssembly.Location) ?? string.Empty)); | ||
}); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
....Service.Test/Runtime/ReadingResources.cs → ...ipe.Service.Test/Core/ReadingResources.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
27 changes: 27 additions & 0 deletions
27
test/recipe/Baked.Test.Recipe.Service.Test/Core/ReadingResourcesDuringTests.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,27 @@ | ||
using Microsoft.Extensions.FileProviders; | ||
|
||
namespace Baked.Test.Core; | ||
|
||
public class ReadingResourcesDuringTests : TestServiceSpec | ||
{ | ||
[TestCase("Core/DomainEmbedded.txt")] | ||
public void Specs_includes_business_resources(string subpath) | ||
{ | ||
var provider = GiveMe.The<IFileProvider>(); | ||
|
||
var exists = provider.Exists(subpath); | ||
|
||
exists.ShouldBeTrue(); | ||
} | ||
|
||
[TestCase("Core/ApplicationEmbedded.txt")] | ||
[TestCase("Core/ApplicationPhysical.txt")] | ||
public void Specs_excludes_application_resources(string subpath) | ||
{ | ||
var provider = GiveMe.The<IFileProvider>(); | ||
|
||
var exists = provider.Exists(subpath); | ||
|
||
exists.ShouldBeFalse(); | ||
} | ||
} |