Base solution for your next web application
Open Closed

Why test assembly can access internal class of abp assembly? #440


User avatar
0
hugan created

Hi, I has found that in test project of ABP, test class can access internal class of ABP, that really confused me. I create a test solution bu it didn't work work.

Is there any secret? :?: :?:


3 Answer(s)
  • User Avatar
    0
    theedge created

    Can you supply some code?

  • User Avatar
    0
    hugan created

    Well, here is a sample.

    This is the test code,that in UnitOfWorkManager_Tests class of Abp.Tests projoect, at row 16 ~ 21:

    LocalIocManager.IocContainer.Register(
                    Component.For<IUnitOfWorkDefaultOptions>().ImplementedBy<UnitOfWorkDefaultOptions>().LifestyleSingleton(),
                    Component.For<ICurrentUnitOfWorkProvider>().ImplementedBy<CallContextCurrentUnitOfWorkProvider>().LifestyleSingleton(),
                    Component.For<IUnitOfWorkManager>().ImplementedBy<UnitOfWorkManager>().LifestyleSingleton(),
                    Component.For<IUnitOfWork>().UsingFactoryMethod(() => fakeUow).LifestyleSingleton()
                    );
    

    but the UnitOfWorkDefaultOptions and UnitOfWorkManager live in Abp project, and is really internal class, such as :

    internal class UnitOfWorkDefaultOptions : IUnitOfWorkDefaultOptions
    
    internal class UnitOfWorkManager : IUnitOfWorkManager, ITransientDependency
    

    May be I miss something?

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Yes, ABP unit tests access to internals of ABP. This is normal. Otherwise, how can I test internal classes of ABP? But you don't need to access it's internals since you're not testing ABP. Have you checked this article: <a class="postlink" href="http://www.codeproject.com/Articles/871786/Unit-testing-in-Csharp-using-xUnit-Entity-Framewor">http://www.codeproject.com/Articles/871 ... y-Framewor</a>