diff options
author | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-08-07 19:32:26 +0300 |
---|---|---|
committer | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-08-07 19:32:26 +0300 |
commit | 87513d0fc80db7df76feeeda996bb69c7c85fa3b (patch) | |
tree | 8756c5d507f3797f011080116642ab533a8e6f9f /main/tests | |
parent | dd19d5a12437cf88d0d9d136dd76ad7edaf61089 (diff) | |
parent | b6e403e5402c9696e27fb23a494c5e4596281696 (diff) |
Merge branch 'master' into vsts-866545-objectvaluetreeview
Diffstat (limited to 'main/tests')
7 files changed, 165 insertions, 23 deletions
diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/FilePathTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/FilePathTests.cs index 6d3bad23c5..f43f41eaba 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/FilePathTests.cs +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Core/FilePathTests.cs @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using NUnit.Framework; @@ -111,21 +112,58 @@ namespace MonoDevelop.Core Assert.IsFalse (child.IsChildPathOf (child)); } - [Test] - public void FileExtensionIsProper () + [TestCase("test.txt", "test")] + [TestCase(".gitignore", "")] + public void FileNameWithoutExtension (string fileName, string expected) + { + var path = FilePath.Build ("dir", fileName); + + Assert.AreEqual (expected, path.FileNameWithoutExtension); + } + + + [TestCase ("test.txt", ".txt", true)] + [TestCase ("test.txt", ".TxT", null)] + [TestCase ("test.txt", ".cs", false)] + [TestCase ("test.txt", ".longer", false)] + [TestCase ("test.txt", "", false)] + [TestCase (".gitignore", ".gitignore", true)] + [TestCase (".gitignore", ".git", false)] + [TestCase (".gitignore", "", false)] + [TestCase ("a", "", true)] + [TestCase ("a.", "", true)] + [TestCase ("", "", true)] + [TestCase ("", "a", false)] + public void HasExtensionChecks (string fileName, string assertExtension, bool? expected) { - var path = new FilePath ("asdf.txt"); - Assert.AreEqual ("asdf.txt", path.FileName); - Assert.IsTrue (path.HasExtension (".txt")); - Assert.AreEqual (FilePath.PathComparison == StringComparison.OrdinalIgnoreCase, path.HasExtension (".TXT")); - Assert.AreEqual (".txt", path.Extension); - Assert.AreEqual ("asdf", path.FileNameWithoutExtension); - - path = new FilePath (".gitignore"); - Assert.False (path.HasExtension (".gitignore")); - Assert.AreEqual (".gitignore", path.FileName); - Assert.AreEqual (".gitignore", path.Extension); - Assert.AreEqual ("", path.FileNameWithoutExtension); + IEqualityComparer<string> comparer = FilePath.PathComparer; + var expectedValue = expected ?? FilePath.PathComparison == StringComparison.OrdinalIgnoreCase; + + var path = FilePath.Build ("dir", fileName); + + Assert.AreEqual (expectedValue, path.HasExtension (assertExtension)); + + var expectedConstraint = expectedValue ? Is.EqualTo (assertExtension) : Is.Not.EqualTo (assertExtension); + Assert.That (path.Extension, expectedConstraint.Using (comparer)); + } + + [TestCase ("test.txt", "test.txt", true)] + [TestCase ("test.txt", "Test.txT", null)] + [TestCase ("test.txt", "abc.txt", false)] + [TestCase ("test.txt", "something", false)] + [TestCase (".gitignore", ".gitignore", true)] + [TestCase (".gitignore", ".git", false)] + public void HasFileNameChecks (string fileName, string assertFileName, bool? expected) + { + IEqualityComparer<string> comparer = FilePath.PathComparer; + var expectedValue = expected ?? FilePath.PathComparison == StringComparison.OrdinalIgnoreCase; + + var path = FilePath.Build ("dir", fileName); + + Assert.AreEqual (expectedValue, path.HasFileName (assertFileName)); + + var expectedConstraint = expectedValue ? Is.EqualTo (assertFileName) : Is.Not.EqualTo (assertFileName); + Assert.That (path.FileName, expectedConstraint.Using (comparer)); } [Test] diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs index 7b3738aa59..fbfe4e9454 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/MSBuildProjectTests.cs @@ -494,6 +494,20 @@ namespace MonoDevelop.Projects var specialFolder = Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData); Assert.AreEqual (specialFolder, p.EvaluatedProperties.GetValue ("EnumFolderPath")); + var path = p.EvaluatedProperties.GetValue ("Path"); + + Assert.AreEqual ( + path.Split (Path.DirectorySeparatorChar).Length, + p.EvaluatedProperties.GetValue<int> ("EnumFlagsSplitStringLength") + ); + Assert.AreEqual ( + path.Split (new [] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).Length, + p.EvaluatedProperties.GetValue<int> ("EnumFlagsSplitStringRemoveEmptyLength") + ); + + Assert.AreEqual ("1", p.EvaluatedProperties.GetValue ("CorrectOverloadIndexOf")); + Assert.AreEqual ("a.cs;b.cs", p.EvaluatedProperties.GetValue ("CorrectOverloadIndexOfTransform")); + var basePath = Path.GetDirectoryName (p.FileName); var targets = Path.Combine (basePath, "false.targets"); diff --git a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/ProjectWithWildcardsTests.cs b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/ProjectWithWildcardsTests.cs index 97cf87adf3..8bf1f13c7d 100644 --- a/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/ProjectWithWildcardsTests.cs +++ b/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/ProjectWithWildcardsTests.cs @@ -1,4 +1,4 @@ -// +// // ProjectWithWildcardsTests.cs // // Author: @@ -63,6 +63,31 @@ namespace MonoDevelop.Projects } [Test] + public async Task LoadProjectWithQuestionWildcards () + { + string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject-with-question-wildcard.csproj"); + + var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile); + Assert.IsInstanceOf<Project> (p); + var mp = (Project)p; + var files = mp.Files.Select (f => f.FilePath.FileName).OrderBy (f => f).ToArray (); + Assert.That (files, Is.EquivalentTo (new string [] { + "Data1.cs", + "Data2.cs", + "Data3.cs", + "maybe.js", + "maybe1.js", + "Program.cs", + "text1-1.txt", + "text1-2.txt", + "text2-1.txt", + "text2-2.txt", + })); + + p.Dispose (); + } + + [Test] public async Task LoadProjectWithWildcardsAndExcludes () { string projFile = Util.GetSampleProject ("console-project-with-wildcards", "ConsoleProject-with-excludes.csproj"); @@ -338,7 +363,7 @@ namespace MonoDevelop.Projects } /// <summary> - /// If an MSBuild item has a property on loading then if all the properties are removed the + /// If an MSBuild item has a property on loading then if all the properties are removed the /// project file when saved will still have an end element. So this test uses a different /// .saved5 file compared with the previous test and includes the extra end tag for the /// EmbeddedResource. diff --git a/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-with-question-wildcard.csproj b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-with-question-wildcard.csproj new file mode 100755 index 0000000000..c94386b696 --- /dev/null +++ b/main/tests/test-projects/console-project-with-wildcards/ConsoleProject-with-question-wildcard.csproj @@ -0,0 +1,51 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{4A9E3523-48F0-4BDF-A0F4-49DAD4431FAB}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>ConsoleProject</RootNamespace> + <AssemblyName>ConsoleProject</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>True</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>False</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>True</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Content\**\*.cs" /> + <Content Include="Content\*.txt" /> + <Content Include="Content\Data\*.txt" /> + <Content Include="maybe?.js" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> diff --git a/main/tests/test-projects/console-project-with-wildcards/maybe.js b/main/tests/test-projects/console-project-with-wildcards/maybe.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/main/tests/test-projects/console-project-with-wildcards/maybe.js diff --git a/main/tests/test-projects/console-project-with-wildcards/maybe1.js b/main/tests/test-projects/console-project-with-wildcards/maybe1.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/main/tests/test-projects/console-project-with-wildcards/maybe1.js diff --git a/main/tests/test-projects/msbuild-tests/functions.csproj b/main/tests/test-projects/msbuild-tests/functions.csproj index 5a96bebf3f..217f855153 100755 --- a/main/tests/test-projects/msbuild-tests/functions.csproj +++ b/main/tests/test-projects/msbuild-tests/functions.csproj @@ -1,10 +1,20 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> - <ItemGroup> + <ItemGroup> <File Include="$(P1).$(Prefix)Test1" /> <Result Include="$(Files)" /> - </ItemGroup> - <PropertyGroup> + <DesignerCS Include="a.designer.cs;b.designer.cs"/> + <DesignerCSDependentFiles Include="@(DesignerCS)"> + <DependentUpon>$([System.String]::Copy('%(Identity)').Substring( + 0, + $([System.String]::Copy('%(Identity)').LastIndexOf( + '.designer.cs', + System.StringComparison.OrdinalIgnoreCase)) + )).cs + </DependentUpon> + </DesignerCSDependentFiles> + </ItemGroup> + <PropertyGroup> <Prop>abcdefgh</Prop> <SomeChars>1.0</SomeChars> <TestFile>files\test.txt</TestFile> @@ -37,7 +47,7 @@ <CharTrim>$(Path.Trim (\b))</CharTrim> <OutDir>foo</OutDir> <FullPath>$([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `$(OutDir)`))`))</FullPath> - <FullPathWithSpaces>$([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `(a b)`))`))</FullPathWithSpaces> + <FullPathWithSpaces>$([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `(a b)`))`))</FullPathWithSpaces> <P1>AAA</P1> <Files>$(P1);@(File)</Files> <Prefix>Post</Prefix> @@ -47,14 +57,18 @@ <DoubleNumberComplex>$([MSBuild]::Subtract($(DoubleNumber.Split('.')[0].Substring(3).Trim()), 8800))</DoubleNumberComplex> <ParamsPathCombine>$([System.IO.Path]::Combine('a', 'b', 'c', 'd', 'e', 'f'))</ParamsPathCombine> <EnumFolderPath>$([System.Environment]::GetFolderPath(SpecialFolder.LocalApplicationData))</EnumFolderPath> + <EnumFlagsSplitStringLength>$(Path.Split('\', StringSplitOptions.None).Length)</EnumFlagsSplitStringLength> + <EnumFlagsSplitStringRemoveEmptyLength>$(Path.Split('\', System.StringSplitOptions.None|RemoveEmptyEntries).Length)</EnumFlagsSplitStringRemoveEmptyLength> <DirectoryNameOfFileAbove>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), false.targets))false.targets</DirectoryNameOfFileAbove> <PathOfFileAbove>$([MSBuild]::GetPathOfFileAbove('false.targets'))</PathOfFileAbove> <EnsureTrailingSlash>$([MSBuild]::EnsureTrailingSlash('$(CharTrim)'))</EnsureTrailingSlash> <NormalizeDirectory>$([MSBuild]::NormalizeDirectory('$(CharTrim)'))</NormalizeDirectory> <NormalizePath>$([MSBuild]::NormalizePath('$(CharTrim)'))</NormalizePath> - </PropertyGroup> - <PropertyGroup> - </PropertyGroup> + <CorrectOverloadIndexOf>$([System.String]::Copy('a.designer.cs').LastIndexOf('.designer.cs', System.StringComparison.OrdinalIgnoreCase))</CorrectOverloadIndexOf> + <CorrectOverloadIndexOfTransform>@(DesignerCSDependentFiles->'%(DependentUpon)')</CorrectOverloadIndexOfTransform> + </PropertyGroup> + <PropertyGroup> + </PropertyGroup> <Target Name="Test"> <Message Text="$(FullPath)" /> </Target> |