public void GetServiceShouldNotAllowNullServiceType() { // arrange var serviceProvider = new ServiceProviderAdapter( ( t, s ) => new object() ); Type serviceType = null; // act var ex = Assert.Throws<ArgumentNullException>( () => serviceProvider.GetService( serviceType ) ); // assert Assert.Equal( "serviceType", ex.ParamName ); }
public void GetServicesShouldReturnExpectedObjects( IReadOnlyList<Tuple<Type, string, object>> services, Type serviceType, IEnumerable<object> expected ) { // arrange var serviceProvider = new ServiceProviderAdapter( ( t, s ) => services.Where( i => i.Item1 == t && i.Item2 == s ).Select( i => i.Item3 ).FirstOrDefault(), ( t, s ) => services.Where( i => i.Item1 == t && i.Item2 == s ).Select( i => i.Item3 ) ); // act var actual = serviceProvider.GetServices( serviceType ); // assert Assert.True( expected.SequenceEqual( actual ) ); }
public void GetServicesShouldReturnSelfWhenRequested() { // arrange var serviceProvider = new ServiceProviderAdapter( ( t, s ) => null ); var expected = new object[] { serviceProvider }; // act var actual = serviceProvider.GetServices( typeof( IServiceProvider ) ); // assert Assert.True( expected.SequenceEqual( actual ) ); }
public void GetServiceShouldReturnExpectedObject( IReadOnlyList<Tuple<Type, string, object>> services, Type serviceType, object expected ) { // arrange var serviceProvider = new ServiceProviderAdapter( ( t, s ) => services.Where( i => i.Item1 == t && i.Item2 == s ).Select( i => i.Item3 ).FirstOrDefault() ); // act var actual = serviceProvider.GetService( serviceType ); // assert Assert.Equal( expected, actual ); }
public void GetServiceShouldReturnSelfWhenRequested() { // arrange var serviceProvider = new ServiceProviderAdapter( ( t, s ) => null ); // act var actual = serviceProvider.GetService( typeof( IServiceProvider ) ); // assert Assert.Same( serviceProvider, actual ); }