-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed extension ambivalence of IDictionary, IReadyOnlyDictionary and …
…its implementations ignoreCase option added to Enums.ValueOf methods Removed Struct and IConvertible type requirement for Enums utilities Fixed typo in InstanceCreator.CreateInstance method Extensions for CountDownEvent class DateTime extensions: ToDate, Plus and MinusDays
- Loading branch information
Jakub Malek
authored and
Jakub Malek
committed
Jun 13, 2016
1 parent
f2ffeca
commit 324081c
Showing
14 changed files
with
620 additions
and
19 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/Sharpility.Tests/Extensions/CountdownEventExtensionsTests.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,39 @@ | ||
using System.Threading; | ||
using NFluent; | ||
using NUnit.Framework; | ||
using Sharpility.Extensions; | ||
|
||
namespace Sharpility.Tests.Extensions | ||
{ | ||
[TestFixture] | ||
public class CountdownEventExtensionsTests | ||
{ | ||
[Test] | ||
public void ShouldSignalCountDownEvent() | ||
{ | ||
// given | ||
var countDownEvent = new CountdownEvent(1); | ||
|
||
// when | ||
var result = countDownEvent.TrySignal(); | ||
|
||
// then | ||
Check.That(result).IsTrue(); | ||
Check.That(countDownEvent.CurrentCount).IsEqualTo(0); | ||
} | ||
|
||
[Test] | ||
public void ShouldIgnoreSignalingCountDownWhenCurrentCountIsZero() | ||
{ | ||
// given | ||
var countDownEvent = new CountdownEvent(0); | ||
|
||
// when | ||
var result = countDownEvent.TrySignal(); | ||
|
||
// then | ||
Check.That(result).IsFalse(); | ||
Check.That(countDownEvent.CurrentCount).IsEqualTo(0); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Threading; | ||
using Sharpility.Base; | ||
|
||
namespace Sharpility.Extensions | ||
{ | ||
/// <summary> | ||
/// Extensions for CountdownEvent | ||
/// </summary> | ||
public static class CountdownEventExtensions | ||
{ | ||
/// <summary> | ||
/// Signals if current count is greater than zero. | ||
/// </summary> | ||
/// <param name="source">source</param> | ||
public static bool TrySignal(this CountdownEvent source) | ||
{ | ||
Preconditions.IsNotNull(source, () => new NullReferenceException("source")); | ||
if (source.CurrentCount > 0) | ||
{ | ||
try | ||
{ | ||
source.Signal(); | ||
} | ||
catch (ObjectDisposedException) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.