-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setter to TransactionManager.DefaultTimeout and MaxTimeout. (#71703)
* Add setter to TransactionManager.DefaultTimeout and MaxTimeout. * Address review feedback. * Interlocked access timespan to avoid data tear on x86 machine. * Remove redundant Interlocked.Read.
- Loading branch information
1 parent
a413e87
commit 8fc905e
Showing
4 changed files
with
95 additions
and
9 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
31 changes: 31 additions & 0 deletions
31
src/libraries/System.Transactions.Local/tests/TransactionManagerTest.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,31 @@ | ||
// 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.Transactions.Tests | ||
{ | ||
public class TransactionManagerTest | ||
{ | ||
[Fact] | ||
public void DefaultTimeout_MaxTimeout_Set_Get() | ||
{ | ||
TimeSpan tsDefault = TimeSpan.Parse("00:02:00"); | ||
TransactionManager.DefaultTimeout = tsDefault; | ||
Assert.Equal(tsDefault, TransactionManager.DefaultTimeout); | ||
|
||
TimeSpan tsMax = TimeSpan.Parse("00:30:00"); | ||
TransactionManager.MaximumTimeout = tsMax; | ||
Assert.Equal(tsMax, TransactionManager.MaximumTimeout); | ||
|
||
TimeSpan ts = TransactionManager.MaximumTimeout.Add(TimeSpan.FromMinutes(10)); | ||
TransactionManager.DefaultTimeout = ts; | ||
Assert.Equal(tsMax, TransactionManager.MaximumTimeout); | ||
Assert.Equal(TransactionManager.DefaultTimeout, TransactionManager.MaximumTimeout); | ||
|
||
ts = TimeSpan.Parse("-00:01:00"); | ||
Assert.Throws<ArgumentOutOfRangeException>(() => TransactionManager.DefaultTimeout = ts); | ||
Assert.Throws<ArgumentOutOfRangeException>(() => TransactionManager.MaximumTimeout = ts); | ||
} | ||
} | ||
} |