Base solution for your next web application

Activities of "waku"

Answer

Hi, thank you for your replies! They encourage me a lot!

If you have any suggestions, feel free to create issues on ABPHelper's github!

<cite>hikalkan: </cite> Hi,

You can try this: Download the sample application which includes working unit tests (<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-samples/tree/master/SimpleTaskSystem">https://github.com/aspnetboilerplate/as ... TaskSystem</a>) and compare with yours. Maybe your test project's app.config does not contain proper EF configuration.

I changed my app.config, it didn't work either. :cry: What makes me think it's related to dependency injection is that if I remove the RoleManager parameter from my AuthorizationProvider's constructor, then my unit tests are OK.

<cite>hikalkan: </cite> Hi,

That's related to EffortDB initialization, not arelated to injection. I got this exception before.

Go to ParentIf you have used Database.SetInitializer... method in somewhere in your code, it causes that problem. Remove it (at least for tests) and try again.

Sorry, but I don't use Database.SetInitializer method, I use the generated code by template to seed my data, they'are very "standard":

InitialDataBuilder:

public class InitialDataBuilder
    {
        private readonly BMSDbContext _context;

        public InitialDataBuilder(BMSDbContext context)
        {
            _context = context;
        }

        public void Build()
        {
            new DefaultTenantRoleAndUserBuilder(_context).Build();
        }
    }

BMSTestBase:

public abstract class BMSTestBase : AbpIntegratedTestBase
    {
        protected BMSTestBase()
        {
            //Fake DbConnection using Effort!
            LocalIocManager.IocContainer.Register(
                Component.For<DbConnection>()
                    .UsingFactoryMethod(Effort.DbConnectionFactory.CreateTransient)
                    .LifestyleSingleton()
                );

            //Seed initial data
            UsingDbContext(context => new InitialDataBuilder(context).Build());

            LoginAsDefaultTenantAdmin();
        }

Also, I do need the seed data to run my unit tests, so I can't remove them. Maybe I didn't understand your solution, but could you explain more? Thank you!

Showing 1 to 3 of 3 entries