|
| 1 | +// Copyright(c) Microsoft Corporation |
| 2 | +// All rights reserved. |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the License); you may not use |
| 5 | +// this file except in compliance with the License. You may obtain a copy of the |
| 6 | +// License at http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +// |
| 8 | +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS |
| 9 | +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY |
| 10 | +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, |
| 11 | +// MERCHANTABILITY OR NON-INFRINGEMENT. |
| 12 | +// |
| 13 | +// See the Apache Version 2.0 License for specific language governing |
| 14 | +// permissions and limitations under the License. |
| 15 | + |
| 16 | +using System.IO; |
| 17 | +using System.Linq; |
| 18 | +using System.Threading.Tasks; |
| 19 | +using FluentAssertions; |
| 20 | +using Microsoft.Python.Core.IO; |
| 21 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 22 | +using TestUtilities; |
| 23 | + |
| 24 | +namespace Microsoft.Python.Core.Tests { |
| 25 | + [TestClass] |
| 26 | + public class DirectoryInfoProxyTests { |
| 27 | + public TestContext TestContext { get; set; } |
| 28 | + |
| 29 | + [TestInitialize] |
| 30 | + public void TestInitialize() |
| 31 | + => TestEnvironmentImpl.TestInitialize($"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}"); |
| 32 | + |
| 33 | + [TestCleanup] |
| 34 | + public void Cleanup() => TestEnvironmentImpl.TestCleanup(); |
| 35 | + |
| 36 | + [TestMethod, Priority(0)] |
| 37 | + public async Task EnumerateFileSystemInfos() { |
| 38 | + var root = TestData.GetTestSpecificPath(); |
| 39 | + await TestData.CreateTestSpecificFileAsync("a_y.py", "not important"); |
| 40 | + await TestData.CreateTestSpecificFileAsync("b_y.py", "not important"); |
| 41 | + await TestData.CreateTestSpecificFileAsync("c_z.py", "not important"); |
| 42 | + |
| 43 | + var proxy = new DirectoryInfoProxy(root); |
| 44 | + var files = proxy.EnumerateFileSystemInfos(new[] { "*.py" }, new[] { "*z.py" }).OrderBy(x => x.FullName).ToArray(); |
| 45 | + files.Should().HaveCount(2); |
| 46 | + |
| 47 | + files[0].FullName.Should().Be(Path.Combine(root, "a_y.py")); |
| 48 | + files[1].FullName.Should().Be(Path.Combine(root, "b_y.py")); |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments