Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock added to injected IEnumerable<TService> even if a type for TService is registered #25

Closed
slangeder opened this issue Jul 28, 2019 · 0 comments · Fixed by #30
Closed

Comments

@slangeder
Copy link

The following code describes the issue.

[TestFixture]
public class Test
{
	[Test]
	public void MockAddedToEnumerableEvenIfTypeIsRegistered()
	{
		var autoMock = AutoMock.GetLoose(c =>
		{
			c.RegisterType<TestA>().As<ITest>();
			c.RegisterType<TestB>().As<ITest>();

			c.RegisterType<TestWrapper>().As<TestWrapper>();
		});

		var wrapper = autoMock.Create<TestWrapper>();

		Assert.AreEqual(2, wrapper.All.Count());
	}

	public interface ITest
	{
	}

	public class TestA : ITest { }
	public class TestB : ITest { }

	public class TestWrapper
	{
		public IEnumerable<ITest> All { get; }

		public TestWrapper(IEnumerable<ITest> all)
		{
			All = all;
		}
	}
}

I expect the MoqRegistrationHandler not to create mocks for types that I registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant