mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[Chore] System.IO.Abstractions update (#21061)
* System.IO.Abstractions update * fix tests
This commit is contained in:
committed by
GitHub
parent
1c264e0899
commit
887da6dc1a
@@ -2,13 +2,13 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hosts.Helpers;
|
||||
using Hosts.Models;
|
||||
using Hosts.Settings;
|
||||
using Hosts.Tests.Mocks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Settings.UI.Library.Enumerations;
|
||||
@@ -30,13 +30,8 @@ namespace Hosts.Tests
|
||||
[TestMethod]
|
||||
public void Hosts_Exists()
|
||||
{
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
fileSystem.AddFile(service.HostsFilePath, new MockFileData(string.Empty));
|
||||
var result = service.Exists();
|
||||
@@ -47,15 +42,8 @@ namespace Hosts.Tests
|
||||
[TestMethod]
|
||||
public void Hosts_Not_Exists()
|
||||
{
|
||||
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
|
||||
{
|
||||
})
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
var result = service.Exists();
|
||||
|
||||
@@ -76,13 +64,8 @@ namespace Hosts.Tests
|
||||
# 10.1.1.30 host30 host30.local # new entry
|
||||
";
|
||||
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
|
||||
|
||||
@@ -106,13 +89,8 @@ namespace Hosts.Tests
|
||||
@"10.1.1.2 host2 host2.local # another comment
|
||||
";
|
||||
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
|
||||
|
||||
@@ -137,13 +115,8 @@ namespace Hosts.Tests
|
||||
10.1.1.2 host2 host2.local # another comment
|
||||
";
|
||||
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
|
||||
|
||||
@@ -162,11 +135,7 @@ namespace Hosts.Tests
|
||||
[TestMethod]
|
||||
public async Task Empty_Hosts()
|
||||
{
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
@@ -197,14 +166,9 @@ namespace Hosts.Tests
|
||||
10.1.1.2 host2 host2.local # another comment
|
||||
";
|
||||
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
userSettings.Setup(m => m.AdditionalLinesPosition).Returns(AdditionalLinesPosition.Top);
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, _elevationHelper.Object);
|
||||
fileSystem.AddFile(service.HostsFilePath, new MockFileData(content));
|
||||
|
||||
@@ -234,11 +198,7 @@ namespace Hosts.Tests
|
||||
# footer
|
||||
";
|
||||
|
||||
var fileSystem = new MockFileSystem
|
||||
{
|
||||
FileSystemWatcher = new TestFileSystemWatcherFactory(),
|
||||
};
|
||||
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
userSettings.Setup(m => m.AdditionalLinesPosition).Returns(AdditionalLinesPosition.Bottom);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user