// 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.IO; using System.Threading.Tasks; using Microsoft.DotNet.OpenApi.Tests; using Microsoft.Extensions.Tools.Internal; using Xunit; using Xunit.Abstractions; namespace Microsoft.DotNet.OpenApi.Remove.Tests { public class OpenApiRemoveTests : OpenApiTestBase { public OpenApiRemoveTests(ITestOutputHelper output) : base(output) { } [Fact] public async Task OpenApi_Remove_File() { var nswagJsonFile = "openapi.json"; _tempDir .WithCSharpProject("testproj") .WithTargetFrameworks("netcoreapp3.0") .Dir() .WithContentFile(nswagJsonFile) .WithContentFile("Startup.cs") .Create(); var add = GetApplication(); var run = add.Execute(new[] { "add", "file", nswagJsonFile }); Assert.True(string.IsNullOrEmpty(_error.ToString()), $"Threw error: {_error.ToString()}"); Assert.Equal(0, run); // csproj contents var csproj = new FileInfo(Path.Join(_tempDir.Root, "testproj.csproj")); using (var csprojStream = csproj.OpenRead()) using (var reader = new StreamReader(csprojStream)) { var content = await reader.ReadToEndAsync(); Assert.Contains("