Skip to content
代码片段 群组 项目
InteropTestsFixture.cs 1.0 KB
更新 更旧
  • 了解如何忽略特定修订
  • // Copyright (c) .NET Foundation. All rights reserved.
    // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
    
    using System;
    using System.Threading.Tasks;
    using Xunit.Abstractions;
    
    namespace InteropTests.Helpers
    {
        public class InteropTestsFixture : IDisposable
        {
            private WebsiteProcess _process;
    
            public string Path { get; set; }
    
    
            public string ServerPort { get; private set; }
    
    
            public async Task EnsureStarted(ITestOutputHelper output)
            {
                if (_process != null)
                {
                    return;
                }
    
                if (string.IsNullOrEmpty(Path))
                {
                    throw new InvalidOperationException("Path has not been set.");
                }
    
                _process = new WebsiteProcess(Path, output);
    
                await _process.WaitForReady();
    
                ServerPort = _process.ServerPort;
            }
    
            public void Dispose()
            {
                _process.Dispose();
            }
        }
    }