public void AddDependencyResolver_throws_if_the_configuation_is_locked()
            {
                var configuration = new DbConfiguration();
                configuration.Lock();

                Assert.Equal(
                    Strings.ConfigurationLocked("AddDependencyResolver"),
                    Assert.Throws<InvalidOperationException>(
                        () => configuration.AddDependencyResolver(new Mock<IDbDependencyResolver>().Object)).Message);
            }
        public virtual void SetConfiguration(DbConfiguration configuration)
        {
            Contract.Requires(configuration != null);

            configuration = _loader.TryLoadFromConfig(AppConfig.DefaultInstance) ?? configuration;

            if (_configuration == null)
            {
                _configuration = configuration;
                _configuration.Lock();
            }
            else if (_configuration.GetType()
                     != configuration.GetType())
            {
                if (_configuration.GetType()
                    == typeof(DbConfiguration))
                {
                    throw new InvalidOperationException(Strings.DefaultConfigurationUsedBeforeSet(configuration.GetType().Name));
                }

                throw new InvalidOperationException(
                    Strings.ConfigurationSetTwice(configuration.GetType().Name, _configuration.GetType().Name));
            }
        }
            public void Setting_DefaultConnectionFactory_throws_if_the_configuation_is_locked()
            {
                var configuration = new DbConfiguration();
                configuration.Lock();

                Assert.Equal(
                    Strings.ConfigurationLocked("DefaultConnectionFactory"),
                    Assert.Throws<InvalidOperationException>(
                        () => configuration.DefaultConnectionFactory = new Mock<IDbConnectionFactory>().Object).Message);
            }
            public void AddProvider_throws_if_the_configuation_is_locked()
            {
                var configuration = new DbConfiguration();
                configuration.Lock();

                Assert.Equal(
                    Strings.ConfigurationLocked("AddProvider"),
                    Assert.Throws<InvalidOperationException>(
                        () => configuration.AddProvider("Karl", new Mock<DbProviderServices>().Object)).Message);
            }