public void EnsureProvider_unregisters_provider_when_null()
        {
            DependencyResolver.RegisterProvider(typeof(SqlProviderServices), "System.Data.SqlClient");

            DependencyResolver.EnsureProvider("System.Data.SqlClient", null);

            Assert.IsType <LegacyDbProviderServicesWrapper>(
                DependencyResolver.GetService <DbProviderServices>("System.Data.SqlClient"));
        }
 public void EnsureProvider_registers_provider()
 {
     DependencyResolver.EnsureProvider("System.Data.SqlClient", typeof(SqlProviderServices));
     try
     {
         Assert.Same(
             SqlProviderServices.Instance,
             DependencyResolver.GetService <DbProviderServices>("System.Data.SqlClient"));
     }
     finally
     {
         DependencyResolver.UnregisterProvider("System.Data.SqlClient");
     }
 }
        public void DependencyResolver_can_register_unregister_provider()
        {
            DependencyResolver.RegisterProvider(typeof(SqlProviderServices), "System.Data.SqlClient");
            try
            {
                Assert.Same(
                    SqlProviderServices.Instance,
                    DependencyResolver.GetService <DbProviderServices>("System.Data.SqlClient"));
            }
            finally
            {
                DependencyResolver.UnregisterProvider("System.Data.SqlClient");
            }

            Assert.IsType <LegacyDbProviderServicesWrapper>(
                DependencyResolver.GetService <DbProviderServices>("System.Data.SqlClient"));
        }
Example #4
0
 public static T GetService <T>(object key = null) where T : class
 {
     return((T)Instance.GetService(typeof(T), key));
 }
 public void DependencyResolver_does_not_resolve_Object()
 {
     Assert.Null(DependencyResolver.GetService <object>());
 }
 public void DependencyResolver_resolves_IPluralizationService()
 {
     Assert.NotNull(DependencyResolver.GetService <IPluralizationService>());
 }
 public void DependencyResolver_resolves_IDbProviderServicesFactory()
 {
     Assert.NotNull(DependencyResolver.GetService <DbProviderServices>("System.Data.SqlClient"));
 }