Created
November 14, 2019 15:32
-
-
Save chsami/7a35f9dc2d02e48e0f5e357421495f64 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| [TestClass] | |
| public abstract class BaseTest | |
| { | |
| public static ServiceProvider serviceProvider; | |
| public IMyService _myService; | |
| [AssemblyInitialize] | |
| public static void SetUp(TestContext context) | |
| { | |
| IServiceCollection services = new ServiceCollection(); | |
| services.AddTransient<IMyService, MyService>(); | |
| //build services | |
| serviceProvider = services.BuildServiceProvider(); | |
| } | |
| [TestInitialize] | |
| public void InitializeTest() | |
| { | |
| //resolve services | |
| _myService = serviceProvider.GetService<IMyService>(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment