Access App.Config Settings from Class Library Called through Unit Test Project

前端 未结 4 2052
暗喜
暗喜 2021-02-06 10:26

I have the following setup:

  • ASP.net 3.5 Web Site Project
  • C# Class Library with business logic
  • C# Class Library for unit testing

Th

4条回答
  •  暖寄归人
    2021-02-06 10:50

    I'd recommend changing the design such that your business-logic layer, instead of having the responsibility to locate configuration settings, is injected with them.

    Your Web app could inject settings it reads from its Web.config file, while your unit test could inject different settings (e.g. connection string to a test database, etc.)

提交回复
热议问题