forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose AppContext.SetData in ref assembly (dotnet#62996)
* Expose AppContext.SetData in ref assembly * Implement test for Set/GetData * Add doc comment
- Loading branch information
Showing
6 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
src/libraries/System.Runtime/tests/System/AppContext/AppContextTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Xunit; | ||
|
||
namespace System.Tests | ||
{ | ||
public partial class AppContextTests | ||
{ | ||
[Theory] | ||
[InlineData("AppContext_Case1", 123)] | ||
[InlineData("AppContext_Case2", "")] | ||
[InlineData("AppContext_Case3", null)] | ||
public void AppContext_GetSetDataTest(string dataKey, object value) | ||
{ | ||
// Set data | ||
AppContext.SetData(dataKey, value); | ||
|
||
// Get previously set data | ||
object actual = AppContext.GetData(dataKey); | ||
|
||
// Validate instance equality | ||
Assert.Same(value, actual); | ||
} | ||
|
||
[Fact] | ||
public void AppContext_ThrowTest() | ||
{ | ||
AssertExtensions.Throws<ArgumentNullException>("name", () => AppContext.SetData(null, 123)); | ||
} | ||
} | ||
} |