mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:12:56 +08:00
Workaround interface mocks in TestSceneFirstRunSetupOverlay
breaking with hot reload
This commit is contained in:
parent
a6674d8c1a
commit
14a21e9224
@ -4,9 +4,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
@ -25,9 +27,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
private FirstRunSetupOverlay overlay;
|
||||
|
||||
private readonly Mock<IPerformFromScreenRunner> performer = new Mock<IPerformFromScreenRunner>();
|
||||
private readonly Mock<TestPerformerFromScreenRunner> performer = new Mock<TestPerformerFromScreenRunner>();
|
||||
|
||||
private readonly Mock<INotificationOverlay> notificationOverlay = new Mock<INotificationOverlay>();
|
||||
private readonly Mock<TestNotificationOverlay> notificationOverlay = new Mock<TestNotificationOverlay>();
|
||||
|
||||
private Notification lastNotification;
|
||||
|
||||
@ -37,8 +39,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
private void load()
|
||||
{
|
||||
Dependencies.Cache(LocalConfig = new OsuConfigManager(LocalStorage));
|
||||
Dependencies.CacheAs(performer.Object);
|
||||
Dependencies.CacheAs(notificationOverlay.Object);
|
||||
Dependencies.CacheAs<IPerformFromScreenRunner>(performer.Object);
|
||||
Dependencies.CacheAs<INotificationOverlay>(notificationOverlay.Object);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
@ -196,5 +198,31 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddAssert("overlay shown", () => overlay.State.Value == Visibility.Visible);
|
||||
AddAssert("is resumed", () => overlay.CurrentScreen is ScreenBeatmaps);
|
||||
}
|
||||
|
||||
// interface mocks break hot reload, mocking this stub implementation instead works around it.
|
||||
// see: https://github.com/moq/moq4/issues/1252
|
||||
[UsedImplicitly]
|
||||
public class TestNotificationOverlay : INotificationOverlay
|
||||
{
|
||||
public virtual void Post(Notification notification)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Hide()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual IBindable<int> UnreadCount => null;
|
||||
}
|
||||
|
||||
// interface mocks break hot reload, mocking this stub implementation instead works around it.
|
||||
// see: https://github.com/moq/moq4/issues/1252
|
||||
[UsedImplicitly]
|
||||
public class TestPerformerFromScreenRunner : IPerformFromScreenRunner
|
||||
{
|
||||
public virtual void PerformFromScreen(Action<IScreen> action, IEnumerable<Type> validScreens = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user