jordanlytle / SmbAbstraction

Implements the System.IO.Abstractions interfaces for interacting with the filesystem, and adds support for interacting with UNC or SMB paths
MIT License
6 stars 8 forks source link

Create `string path` helper extensions and create tests #1

Closed Jo0 closed 4 years ago

Jo0 commented 4 years ago

Path Extension

Created extension methods and accompanying unit tests for string path to determine

Updated instances of handling string path with new Uri(path)

From To
if (!IsSMBPath(path)) { return base.CreateDirectory(path); } if (!path.IsSmbPath()) { return base.CreateDirectory(path); }
Uri uri = new Uri(path); if (uri.Segments.Length < 2) { return null; } var hostEntry = Dns.GetHostEntry(uri.Host); if (path.IsValidSharePath()) { return null; } var hostEntry = Dns.GetHostEntry(path.HostName());
var shareName = uri.Segments[1].Replace(Path.DirectorySeparatorChar.ToString(), ""); var newPath = uri.AbsolutePath.Replace(uri.Segments[1], "").Remove(0, 1).Replace('/', '\\'); var shareName = path.ShareName(); var relativePath = path.RelativeSharePath();

Tests

Unit Tests

Integration Tests