1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using CZFW.Core;
- using CZFW.Framework;
- using CZFW.Framework.Logic;
- using CZFW.Framework.Model;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- namespace CZKJ.GBRS2.Test
- {
- public class TestBase
- {
- public TestBase()
- {
- ServiceProvider = TestDI.ServiceProvider;
- }
- public ServiceProvider ServiceProvider { get; set; }
- public TInterface GetService<TInterface>()
- {
- return ServiceProvider.GetService<TInterface>();
- }
- }
- public static class TestDI
- {
- private static ServiceProvider serviceProvider;
- public static ServiceProvider ServiceProvider
- {
- get
- {
- if (serviceProvider == null)
- {
- IServiceCollection service = new ServiceCollection();
- service.ConfigServies();
- service.AddLogging();
- service.ConfigureFrameworkServices();
- serviceProvider = service.BuildServiceProvider();
-
- CZHttpContext.ServiceProvider = serviceProvider;
- var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
- ConfigHelper.Configs = builder.Build();
- }
- return serviceProvider;
- }
- }
- }
- }
|