public void GetServicesOfTShouldReturnExpectedInstances() { // arrange var serviceProvider = new Mock<IServiceProvider>(); var expected = new[] { new object(), new object(), new object() }; serviceProvider.Setup( sp => sp.GetService( It.IsAny<Type>() ) ).Returns( expected.ToArray() ); // act var actual = serviceProvider.Object.GetServices<object>(); // assert Assert.True( expected.SequenceEqual( actual ) ); serviceProvider.Verify( sp => sp.GetService( typeof( IEnumerable<object> ) ), Times.Once() ); }