-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ViewModels.ViewModelLocator
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
ThScoreFileConverter.Tests/ViewModels/ViewModelLocatorTests.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,33 @@ | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using MvvmDialogs; | ||
using NSubstitute; | ||
using ThScoreFileConverter.Adapters; | ||
using ThScoreFileConverter.Models; | ||
using ThScoreFileConverter.ViewModels; | ||
|
||
namespace ThScoreFileConverter.Tests.ViewModels; | ||
|
||
[TestClass] | ||
public class ViewModelLocatorTests | ||
{ | ||
[TestMethod] | ||
public void MainWindowTest() | ||
{ | ||
using var provider = new ServiceCollection() | ||
.AddSingleton(Substitute.For<IDialogService>()) | ||
.AddSingleton(Substitute.For<IDispatcherAdapter>()) | ||
.AddSingleton(Substitute.For<IResourceDictionaryAdapter>()) | ||
.AddSingleton(new Settings()) | ||
.AddSingleton(Substitute.For<INumberFormatter>()) | ||
.AddTransient<MainWindowViewModel>() | ||
.BuildServiceProvider(); | ||
|
||
Ioc.Default.ConfigureServices(provider); | ||
|
||
using var window = new ViewModelLocator().MainWindow; | ||
Assert.IsNotNull(window); | ||
|
||
// NOTE: Ioc.Default can't be configured twice. | ||
} | ||
} |