1
 [ClassInitialize]
    public static void ReportClassSetup(TestContext context)
    {
        BaseAdapter.ConnectionString = ConfigurationManager.ConnectionStrings["PremierConfig"].ConnectionString;
        IServiceContext serviceContext = new ServiceContextTest();
        var backgroundQueueService = new Camp.Core.Queue.DedicatedThreadTaskQueueService("PremierWebQueueService");
        backgroundQueueService.Start();
        var internalLoggerBackgroundService = new InternalLoggerBackgroundService()
        {
            QueueService = backgroundQueueService
        };
        _service = new InternalService(new DummyAuthorizationManager(), null, null)
        {
            ServiceContext = serviceContext,
            InternalLoggerBackgroundService = internalLoggerBackgroundService
        };
    }

    [TestInitialize]
    public void ReportTestSetup()
    {

    }

    [TestMethod]
    public void GetUserActivityReport1()
    {
       Assert.IsNotNull(_service.GetUserActivityReport(1));
    }

在上面的代码中,我可以在 classinitialize 中完成所有初始化和设置,那么 TestInitalize 的确切用途是什么?

4

0 回答 0