-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* added possibility to clear queued toasts (#175) * implemented clearqueue tests (#175) * added clearqueue to ui (#175) Co-authored-by: Samuel Flatscher <[email protected]> Co-authored-by: Chris Sainty <[email protected]>
- Loading branch information
1 parent
b98176e
commit 4f98e1e
Showing
15 changed files
with
397 additions
and
4 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
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
17 changes: 17 additions & 0 deletions
17
tests/Blazored.Toast.Tests/ToastServiceTests/Base/BaseClearQueueTest.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,17 @@ | ||
using Blazored.Toast.Services; | ||
using Xunit; | ||
|
||
namespace Blazored.Toast.Tests.ToastServiceTests.Base | ||
{ | ||
public abstract class BaseClearQueueTest : BaseClearTest | ||
{ | ||
protected abstract ToastLevel _toastLevel { get; } | ||
|
||
protected Action<Action<ToastLevel>?> _eventAction; | ||
|
||
protected BaseClearQueueTest() : base() | ||
{ | ||
_eventAction = x => _sut.OnClearQueueToasts += x; | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
tests/Blazored.Toast.Tests/ToastServiceTests/Base/BaseClearTest.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,76 @@ | ||
using Blazored.Toast.Services; | ||
using System.Reflection.Metadata; | ||
using Xunit; | ||
|
||
namespace Blazored.Toast.Tests.ToastServiceTests.Base | ||
{ | ||
public abstract class BaseClearTest | ||
{ | ||
protected readonly ToastService _sut; | ||
|
||
protected BaseClearTest() | ||
{ | ||
_sut = new ToastService(); | ||
} | ||
|
||
#region OnClearInvoked | ||
protected void OnClearInvoked_When_ClearCalled(Action<Action?> eventAction, Action call) | ||
{ | ||
// arrange | ||
var onClearCalled = false; | ||
eventAction(() => onClearCalled = true); | ||
|
||
// act | ||
call(); | ||
|
||
// assert | ||
Assert.True(onClearCalled); | ||
} | ||
|
||
protected void OnClearInvoked_When_ClearCalled(Action<Action<ToastLevel>?> eventAction, Action call) | ||
{ | ||
// arrange | ||
var onClearCalled = false; | ||
eventAction((_) => onClearCalled = true); | ||
|
||
// act | ||
call(); | ||
|
||
// assert | ||
Assert.True(onClearCalled); | ||
} | ||
|
||
protected void OnClearInvoked_When_ClearCalled(Action<Action<ToastLevel>?> eventAction, Action<ToastLevel> call, ToastLevel level) | ||
{ | ||
// arrange | ||
var onClearCalled = false; | ||
eventAction((_) => onClearCalled = true); | ||
|
||
// act | ||
call(level); | ||
|
||
// assert | ||
Assert.True(onClearCalled); | ||
} | ||
#endregion | ||
|
||
#region | ||
protected void OnClearToastsContainsToastLevel_When_ClearCalled(Action<Action<ToastLevel>?> eventAction, Action call, ToastLevel level) | ||
{ | ||
// arrange | ||
var toastLevel = ""; | ||
|
||
eventAction((argToastlevel) => toastLevel = argToastlevel.ToString()); | ||
|
||
// act | ||
call(); | ||
|
||
// assert | ||
Assert.Equal(level.ToString(), toastLevel); | ||
} | ||
|
||
protected void OnClearToastsContainsToastLevel_When_ClearCalled(Action<Action<ToastLevel>?> eventAction, Action<ToastLevel> call, ToastLevel level) | ||
=> OnClearToastsContainsToastLevel_When_ClearCalled(eventAction, () => call(level), level); | ||
#endregion | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/Blazored.Toast.Tests/ToastServiceTests/ClearQueueTests/ClearQueue.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,17 @@ | ||
using Blazored.Toast.Services; | ||
using Blazored.Toast.Tests.ToastServiceTests.Base; | ||
using Xunit; | ||
|
||
namespace Blazored.Toast.Tests.ToastServiceTests.ClearQueueTests | ||
{ | ||
public class ClearQueue : BaseClearTest | ||
{ | ||
public ClearQueue() : base() | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void OnClearQueueInvoked_When_ClearQueueCalled() | ||
=> OnClearInvoked_When_ClearCalled(x => _sut.OnClearQueue += x, _sut.ClearQueue); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/Blazored.Toast.Tests/ToastServiceTests/ClearQueueTests/ClearQueueErrorToasts.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,25 @@ | ||
using Blazored.Toast.Services; | ||
using Blazored.Toast.Tests.ToastServiceTests.Base; | ||
using Xunit; | ||
|
||
namespace Blazored.Toast.Tests.ToastServiceTests.ClearQueueTests; | ||
|
||
public class ClearQueueErrorToasts : BaseClearQueueTest | ||
{ | ||
protected override ToastLevel _toastLevel => ToastLevel.Error; | ||
|
||
protected Action _call; | ||
|
||
public ClearQueueErrorToasts() : base() | ||
{ | ||
_call = _sut.ClearQueueErrorToasts; | ||
} | ||
|
||
[Fact] | ||
public void OnClearQueueToastsInvoked_When_ClearQueueErrorToastsCalled() | ||
=> OnClearInvoked_When_ClearCalled(_eventAction, _call); | ||
|
||
[Fact] | ||
public void OnClearQueueToastsContainsToastLevelError_When_ClearQueueErrorToastsCalled() | ||
=> OnClearToastsContainsToastLevel_When_ClearCalled(_eventAction, _call, _toastLevel); | ||
} |
Oops, something went wrong.