diff --git a/src/FileSystem/src/Adapters/Adapter.cs b/src/FileSystem/src/Adapters/Adapter.cs index 85998fb..c4c35e9 100644 --- a/src/FileSystem/src/Adapters/Adapter.cs +++ b/src/FileSystem/src/Adapters/Adapter.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Maurosoft.FileSystem.Models; using Serilog; -using Serilog.Core; using DirectoryNotFoundException = Maurosoft.FileSystem.Exceptions.DirectoryNotFoundException; using FileNotFoundException = Maurosoft.FileSystem.Exceptions.FileNotFoundException; @@ -297,7 +296,15 @@ public void WriteFile(string path, string contents, bool overwrite = false) protected string[] GetPathParts(string path) => path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - protected string GetLastPathPart(string path) => GetPathParts(path).Length > 0 ? GetPathParts(path).Last() : String.Empty; + protected string GetLastPathPart(string path) + { + var pathParts = GetPathParts(path); + + if (pathParts.Length > 0) + return pathParts[pathParts.Length - 1]; + else + return String.Empty; + } protected string GetParentPathPart(string path) { diff --git a/tests/FileSystem.Tests/FileSystem.Adapters.Ftp/FtpFixture.cs b/tests/FileSystem.Tests/FileSystem.Adapters.Ftp/FtpFixture.cs index 3914d81..fe0e7e3 100644 --- a/tests/FileSystem.Tests/FileSystem.Adapters.Ftp/FtpFixture.cs +++ b/tests/FileSystem.Tests/FileSystem.Adapters.Ftp/FtpFixture.cs @@ -39,11 +39,9 @@ public FtpFixture() if (Environment.GetEnvironmentVariable("DOCKER_HOST") == null) Environment.SetEnvironmentVariable("DOCKER_HOST", "unix:///var/run/docker.sock"); - userName = faker.Internet.UserName(); + userName = faker.Random.String2(10, 15); password = faker.Internet.Password(); - userName = Regex.Replace(userName, @"[^a-zA-Z0-9_]+", ""); - var passivePortEnd = PassivePortStart + (MaxUsersCount); var containerBuilder = new ContainerBuilder() diff --git a/tests/FileSystem.Tests/FileSystem.Adapters.Sftp/SftpFixture.cs b/tests/FileSystem.Tests/FileSystem.Adapters.Sftp/SftpFixture.cs index d5d3664..d8a29cd 100644 --- a/tests/FileSystem.Tests/FileSystem.Adapters.Sftp/SftpFixture.cs +++ b/tests/FileSystem.Tests/FileSystem.Adapters.Sftp/SftpFixture.cs @@ -35,11 +35,9 @@ public SftpFixture() if (Environment.GetEnvironmentVariable("DOCKER_HOST") == null) Environment.SetEnvironmentVariable("DOCKER_HOST", "unix:///var/run/docker.sock"); - userName = faker.Internet.UserName(); + userName = faker.Random.String2(10, 15); password = faker.Internet.Password(); - userName = Regex.Replace(userName, @"[^a-zA-Z0-9_]+", ""); - var containerBuilder = new ContainerBuilder() .WithName(Guid.NewGuid().ToString("D")) .WithAutoRemove(autoRemove: false) diff --git a/tests/FileSystem.Tests/PriorityOrderer.cs b/tests/FileSystem.Tests/PriorityOrderer.cs deleted file mode 100644 index 26d95cd..0000000 --- a/tests/FileSystem.Tests/PriorityOrderer.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace FileSystem.Tests; -public class PriorityOrderer : ITestCaseOrderer -{ - public IEnumerable OrderTestCases( - IEnumerable testCases) where TTestCase : ITestCase - { - string assemblyName = typeof(TestPriorityAttribute).AssemblyQualifiedName!; - var sortedMethods = new SortedDictionary>(); - foreach (TTestCase testCase in testCases) - { - int priority = testCase.TestMethod.Method - .GetCustomAttributes(assemblyName) - .FirstOrDefault() - ?.GetNamedArgument(nameof(TestPriorityAttribute.Priority)) ?? 9999; - - GetOrCreate(sortedMethods, priority).Add(testCase); - } - - foreach (TTestCase testCase in - sortedMethods.Keys.SelectMany( - priority => sortedMethods[priority].OrderBy( - testCase => testCase.TestMethod.Method.Name))) - { - yield return testCase; - } - } - - private static TValue GetOrCreate( - IDictionary dictionary, TKey key) - where TKey : struct - where TValue : new() => - dictionary.TryGetValue(key, out TValue? result) - ? result - : (dictionary[key] = new TValue()); -} diff --git a/tests/FileSystem.Tests/TestPriorityAttribute.cs b/tests/FileSystem.Tests/TestPriorityAttribute.cs deleted file mode 100644 index 7f1f04d..0000000 --- a/tests/FileSystem.Tests/TestPriorityAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FileSystem.Tests; - -[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -public class TestPriorityAttribute : Attribute -{ - public int Priority { get; private set; } - - public TestPriorityAttribute(int priority) => Priority = priority; -}