//输出,只能注入

 

public class MyUnitTest
    {
        private IServiceCollection service;
        private readonly ITestOutputHelper output;
        public MyUnitTest(ITestOutputHelper tempOutput)
        {
            output = tempOutput;// new TestOutputHelper();
            service = new ServiceCollection();
            service.AddmyMiddleware();
            service.BuildServiceProvider();

        }
        [Fact]
        public void test()
        {

        }

        [Fact]
        public void WritLine()
        {
            output.WriteLine("hi");
        }
    }

 

相关文章:

  • 2021-11-21
  • 2021-08-24
  • 2022-01-01
  • 2021-08-24
  • 2021-06-21
  • 2021-06-29
  • 2022-12-23
猜你喜欢
  • 2021-07-12
  • 2021-11-29
  • 2021-05-19
  • 2021-11-11
  • 2021-08-22
相关资源
相似解决方案