| 1 |
// Licensed to the .NET Foundation under one or more agreements. |
| 2 |
// The .NET Foundation licenses this file to you under the MIT license. |
| 3 |
// See the LICENSE file in the project root for more information. |
| 4 |
|
| 5 |
using System; |
| 6 |
using System.Security.AccessControl; |
| 7 |
using Xunit; |
| 8 |
|
| 9 |
namespace Microsoft.Win32.RegistryTests |
| 10 |
{ |
| 11 |
public class RegistryKey_SetAccessControl_rs : RegistryTestsBase |
| 12 |
{ |
| 13 |
[Fact] |
| 14 |
public void NegativeTests() |
| 15 |
{ |
| 16 |
// Should throw if passed registrySecurity is null |
| 17 |
Assert.Throws<ArgumentNullException>(() => TestRegistryKey.SetAccessControl(null)); |
| 18 |
|
| 19 |
// Should throw if RegistryKey is closed |
| 20 |
Assert.Throws<ObjectDisposedException>(() => |
| 21 |
{ |
| 22 |
TestRegistryKey.Close(); |
| 23 |
TestRegistryKey.SetAccessControl(new RegistrySecurity()); |
| 24 |
}); |
| 25 |
} |
| 26 |
|
| 27 |
[Fact] |
| 28 |
public void SetAccessControlTest() |
| 29 |
{ |
| 30 |
TestRegistryKey.SetAccessControl(TestRegistryKey.GetAccessControl()); |
| 31 |
} |
| 32 |
} |
| 33 |
} |