-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for StartupProcessor, Make StartedAsync faster by paralleliz…
…ing, and small cleanup/refactor
- Loading branch information
Showing
15 changed files
with
100 additions
and
33 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
61 changes: 61 additions & 0 deletions
61
Edge.MyMusic/src/Edge.MyMusic.Tests/StartupProcessorTests.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,61 @@ | ||
using Edge.MyMusic.Processors; | ||
using Edge.MyMusic.Providers; | ||
using Edge.MyMusic.Repositories; | ||
using Edge.MyMusic.Settings; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Edge.MyMusic.Tests; | ||
|
||
public class StartupProcessorTests | ||
{ | ||
private readonly Mock<ILogger<StartupProcessor>> _logger; | ||
private readonly Mock<IMusicRepository> _repo; | ||
private readonly Mock<IAudioProvider> _audioProvider; | ||
private readonly Mock<IArgsSetting> _setting; | ||
|
||
private readonly StartupProcessor _processor; | ||
|
||
public StartupProcessorTests() | ||
{ | ||
_logger = new Mock<ILogger<StartupProcessor>>(); | ||
_repo = new Mock<IMusicRepository>(); | ||
_audioProvider = new Mock<IAudioProvider>(); | ||
_setting = new Mock<IArgsSetting>(); | ||
|
||
_processor = new StartupProcessor(_logger.Object, _repo.Object, _audioProvider.Object, _setting.Object); | ||
} | ||
|
||
[Fact] | ||
public async Task CanStartAsync() | ||
{ | ||
// ACT | ||
await _processor.StartAsync(default); | ||
|
||
// ASSERT | ||
_logger.Verify( | ||
log => log.Log( | ||
It.Is<LogLevel>(l => l == LogLevel.Information), | ||
It.IsAny<EventId>(), | ||
It.Is<It.IsAnyType>((v, t) => v.ToString() == $"{nameof(StartupProcessor)} is starting..."), | ||
It.IsAny<Exception>(), | ||
It.Is<Func<It.IsAnyType, Exception?, string>>((v, t) => true)), | ||
Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task CanStopAsync() | ||
{ | ||
// ACT | ||
await _processor.StopAsync(default); | ||
|
||
// ASSERT | ||
_logger.Verify( | ||
log => log.Log( | ||
It.Is<LogLevel>(l => l == LogLevel.Information), | ||
It.IsAny<EventId>(), | ||
It.Is<It.IsAnyType>((v, t) => v.ToString() == $"{nameof(StartupProcessor)} is stopping..."), | ||
It.IsAny<Exception>(), | ||
It.Is<Func<It.IsAnyType, Exception?, string>>((v, t) => true)), | ||
Times.Once); | ||
} | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
Edge.MyMusic/src/Edge.MyMusic/Settings/IApplicationSetting.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,3 @@ | ||
namespace Edge.MyMusic.Settings; | ||
|
||
public interface IApplicationSetting : ICORSPolicySetting, IArgsSetting, IMongoDBSetting; |
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