Skip to content

Commit

Permalink
DeploymentItem: add test for file deployment using Windows/Linux path… (
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Jul 10, 2023
1 parent 14b6245 commit 0ee0586
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,16 @@ public void ValidateDirectoryDeployment(string targetFramework)
InvokeVsTestForExecution(new string[] { TestAssetPreserveNewest }, testCaseFilter: "DirectoryDeploymentTests", targetFramework: targetFramework);
ValidatePassedTestsContain("DeploymentTestProject.PreserveNewest.DirectoryDeploymentTests.DirectoryWithForwardSlash", "DeploymentTestProject.PreserveNewest.DirectoryDeploymentTests.DirectoryWithBackSlash");
}

public void ValidateFileDeployment_net462()
=> ValidateFileDeployment("net462");

public void ValidateFileDeployment_netcoreapp31()
=> ValidateFileDeployment("netcoreapp3.1");

public void ValidateFileDeployment(string targetFramework)
{
InvokeVsTestForExecution(new string[] { TestAssetPreserveNewest }, testCaseFilter: "FileDeploymentTests", targetFramework: targetFramework);
ValidatePassedTestsContain("DeploymentTestProject.PreserveNewest.FileDeploymentTests.FileWithForwardSlash", "DeploymentTestProject.PreserveNewest.FileDeploymentTests.FileWithBackSlash");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.IO;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DeploymentTestProject.PreserveNewest;
[TestClass]
public class FileDeploymentTests
{
[TestMethod]
[DeploymentItem(@"TestFiles1/some_file1")]
public void FileWithForwardSlash()
{
var fs = File.Open(@"some_file1", FileMode.Open);
fs.Close();
}

[TestMethod]
[DeploymentItem(@"TestFiles2\some_file2")]
public void FileWithBackSlash()
{
var fs = File.Open(@"some_file2", FileMode.Open);
fs.Close();
}
}

0 comments on commit 0ee0586

Please sign in to comment.