Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "joe704la"

in the AppTestBase I added all the seed data for each DB context and it seems to work. Thanks

Thank you for all the help

I want to give a non-admin user access to create and edit a user but I do not want to allow them to add a "Admin" role or change permissions of anyone. I want to limit that to just Admin. I want to give this person more of a "Management" role or something like that. What would be the best way to do this? I know I can easily keep them from editing a user and changing permissions if all I give them is access to create a user but they still can create an "Admin" user which means they could create a separate account for themselves that is Admin role.

Some more info. I tried not using env.GetAppConfiguration and using appConfiguration but that won't find the config file and grab the info from the config file I need.

So I tried this in the test.

public SessionAppService_Tests()
        {
            var fakeHostingEnvironment = Substitute.For<IHostingEnvironment>();
            LocalIocManager.IocContainer.Register(Component.For<IHostingEnvironment>().Instance(fakeHostingEnvironment).IsDefault());

            LocalIocManager.IocContainer.Register(Component.For<IConfigurationRoot>().Instance(fakeHostingEnvironment.GetAppConfiguration()).IsDefault());


            _sessionAppService = Resolve<ISessionAppService>();
        }
    but got the following error. System.ArgumentException : The path must be absolute.
    
    

System.ArgumentException : The path must be absolute. Parameter name: root at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters) at Microsoft.Extensions.Configuration.FileConfigurationExtensions.SetBasePath(IConfigurationBuilder builder, String basePath) at PHS.Configuration.AppConfigurations.BuildConfiguration(String path, String environmentName, Boolean addUserSecrets) in \src\PHS.Core\Configuration\AppConfigurations.cs:line 28 at PHS.Configuration.AppConfigurations.<>c__DisplayClass2_0.<Get>b__0(String _) in \src\PHS.Core\Configuration\AppConfigurations.cs:line 22 at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at PHS.Configuration.AppConfigurations.Get(String path, String environmentName, Boolean addUserSecrets) in \src\PHS.Core\Configuration\AppConfigurations.cs:line 20 at PHS.Configuration.HostingEnvironmentExtensions.GetAppConfiguration(IHostingEnvironment env) in \src\PHS.Core\Configuration\HostingEnvironmentExtensions.cs:line 10 at PHS.Tests.Sessions.SessionAppService_Tests..ctor() in I\test\PHS.Tests\Sessions\SessionAppService_Tests.cs:line 24

Any suggestions?

It looks like I have to use env.GetAppConfiguration because if I don't I get the following error when I run the actual app Sessions.SessionAppService' is waiting for the following dependencies:

  • Service 'Microsoft.Extensions.Configuration.IConfigurationRoot' which was not registered.

That didn't work for me but then I saw you had a difference in your SessionAppService.

I was doing the injection like this _appConfiguration = env.GetAppConfiguration();

Not this _appConfiguration = appConfiguration; If I do it the same way you had it as you can see in my screenshot below. Then it works just fine. Not sure when I should be using the env.GetAppConfiguration(); way over appConfiguration way though. Castle.MicroKernel.ComponentActivator.ComponentActivatorException : ComponentActivator: could not proxy PHS.Sessions.SessionAppService ---- System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. -------- System.ArgumentException : The path must be absolute. Parameter name: root

In my application I have a service that gets data from 3 different databases. This works just fine with 3 different contexts. But now I would like to write an Integration test that tests this service. I am unsure how to do that with 3 different contexts. Does anyone have any suggestions?

No I can't replicate it. I am pretty sure it is because in the services that don't work I am using

private readonly IConfigurationRoot _appConfiguration; and private readonly IHostingEnvironment _env;

so that I can use the appConfiguration to get some configuration settings in the appsettings.json. This works perfectly fine, except when I try to run the tests. Is there anway that you may know of I can register those two interfaces in the testing world?

Like I said I tried doing the following but didn't work. var fakeHostingEnvironment = Substitute.For<IHostingEnvironment>(); IocManager.IocContainer.Register(Component.For<IHostingEnvironment>().Instance(fakeHostingEnvironment).IsDefault());

IocManager.IocContainer.Register(Component.For<IConfigurationRoot>().Instance(FakeAppConfiguration.GetAppConfiguration()).IsDefault());

I am having issues with dependency injection in many of my tests. I basically can't get any of the tests in the ProfileAppService_Tests to work. I get the below.

Castle.MicroKernel.ComponentActivator.ComponentActivatorException : ComponentActivator: could not proxy Authorization.Users.Profile.ProfileAppService ---- System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. -------- System.ArgumentNullException : Value cannot be null.

One thing I noticed was that all the tests that is having issues with certain services are all ones I added IHostingEnvironment and IConfigurationRoot to resolve.

I tried doing something like this in my TestBaseModule but didn't work. var fakeHostingEnvironment = Substitute.For<IHostingEnvironment>(); IocManager.IocContainer.Register(Component.For<IHostingEnvironment>().Instance(fakeHostingEnvironment).IsDefault());

IocManager.IocContainer.Register(Component.For<IConfigurationRoot>().Instance(FakeAppConfiguration.GetAppConfiguration()).IsDefault());

I am pretty new to wiring tests so any help would be a lot of help. Thank you

I found Metronics release notes for version 6. https://keenthemes.com/metronic/?page=docs&section=migration

This should help out.

Showing 21 to 30 of 246 entries