public static void Add_ThrowsArgumentException_ForInvalidInput()
        {
            // Arrange
            var providers = new AssetProviderCollection();
            var provider  = new Mock <ProviderBase>().Object;

            // Act & Assert
            Assert.Throws <ArgumentException>(() => providers.Add(provider));
        }
        public static void Add_ThrowsArgumentNullException_ForNullInput()
        {
            // Arrange
            var          providers = new AssetProviderCollection();
            ProviderBase provider  = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => providers.Add(provider));
        }
Example #3
0
        private static void InitializeDefault()
        {
            // Use the default provider. WARNING: Don't forget to initialize it too!
            var tmpProvider = new DefaultAssetProvider();

            tmpProvider.Initialize(null, null);

            var tmpProviders = new AssetProviderCollection();

            tmpProviders.Add(tmpProvider);
            tmpProviders.SetReadOnly();

            s_Providers = tmpProviders;
            s_Provider  = tmpProvider;
        }
Example #4
0
        // Internal-only method for testing.
        // We use temporary objects to achieve exception-neutral code.
        internal static void InitializeCore(AssetSection section)
        {
            Debug.Assert(section != null);

            // Initialize the provider collection.
            var tmpProviders = new AssetProviderCollection();

            if (section.Providers != null)
            {
                ProvidersHelper.InstantiateProviders(section.Providers, tmpProviders, typeof(AssetProvider));
                tmpProviders.SetReadOnly();
            }

            s_Providers = tmpProviders;

            // Initialize the default provider.
            if (section.DefaultProvider == null)
            {
                throw new ProviderException(Strings.AssetManager_DefaultProviderNotConfigured);
            }

            var tmpProvider = s_Providers[section.DefaultProvider];

            if (tmpProvider == null)
            {
                // section.DefaultProvider is not null => propertyInfo != null.
                var propertyInfo
                    = section.ElementInformation
                      .Properties[AssetSection.DefaultProviderPropertyName];

                throw new ConfigurationErrorsException(
                          Strings.AssetManager_DefaultProviderNotFound,
                          propertyInfo.Source,
                          propertyInfo.LineNumber);
            }

            s_Provider = tmpProvider;
        }