using System.Collections.Generic;
using NUnit.Framework;
namespace System
{
///
/// A set of reusable tests for testing types that implement
/// .
///
public abstract class ServiceProviderTests
{
[Test, Description("Ensures the IServiceProvider.GetService(Type) method " +
"returns a non-null service that is of the proper type " +
"(ICollection in this case), and is equal to " +
"ServiceProviderTests.ExpectedService.")]
public void GetServiceTest()
{
IServiceProvider serviceProvider = CreateServiceProvider();
Type expectedType = typeof (ICollection);
object service = serviceProvider.GetService(expectedType);
Assert.NotNull(service);
Assert.IsInstanceOf(expectedType, service);
Assert.AreEqual(ExpectedService, service);
}
///
/// Creates the to test. This method
/// should always create a new instance. The
/// must contain a service of type that
/// is not null and equal to .
///
/// The instance to test.
protected abstract IServiceProvider CreateServiceProvider();
///
/// The service that is to be contained within the
/// returned by
/// .
///
protected abstract ICollection ExpectedService { get; }
}
}