Skip to content

Commit

Permalink
Add tests for ViewModels.ViewModelLocator
Browse files Browse the repository at this point in the history
  • Loading branch information
y-iihoshi committed Jan 14, 2024
1 parent e56a6e0 commit 281e46e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ThScoreFileConverter.Tests/ViewModels/ViewModelLocatorTests.cs
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.
}
}

0 comments on commit 281e46e

Please sign in to comment.