mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[Hosts]Improved save error handling (#28215)
This commit is contained in:
committed by
GitHub
parent
5e353640d7
commit
6c09565244
@@ -238,5 +238,17 @@ namespace Hosts.Tests
|
||||
var result = fileSystem.GetFile(service.HostsFilePath);
|
||||
Assert.AreEqual(result.TextContents, contentResult);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Save_NotRunningElevatedException()
|
||||
{
|
||||
var fileSystem = new CustomMockFileSystem();
|
||||
var userSettings = new Mock<IUserSettings>();
|
||||
var elevationHelper = new Mock<IElevationHelper>();
|
||||
elevationHelper.Setup(m => m.IsElevated).Returns(false);
|
||||
|
||||
var service = new HostsService(fileSystem, userSettings.Object, elevationHelper.Object);
|
||||
await Assert.ThrowsExceptionAsync<NotRunningElevatedException>(async () => await service.WriteAsync("# Empty hosts file", Enumerable.Empty<Entry>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user