From b99d82cccca7ed3c0fb3ee8568664e2a64772aaa Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 14 Feb 2016 16:26:52 +0100 Subject: [PATCH] Ensure auto-generated mocks are also registered in the test container. --- .../TorrentRssIndexerTests/TorrentRssIndexerFixture.cs | 2 -- src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs index 37e8790fa..01f689d91 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssIndexerFixture.cs @@ -23,8 +23,6 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests [SetUp] public void Setup() { - Mocker.SetConstant(Mocker.GetMock().Object); - Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); Mocker.SetConstant(Mocker.Resolve()); diff --git a/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs b/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs index 1796d715d..98faebac2 100644 --- a/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs +++ b/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs @@ -80,6 +80,8 @@ namespace NzbDrone.Test.Common.AutoMoq { if (_registeredMocks.ContainsKey(type) == false) _registeredMocks.Add(type, mock); + if (mock != null) + _container.RegisterInstance(type, mock.Object); } public virtual void SetConstant(T instance)