Пример #1
0
        public void TestGetExactly()
        {
            var          locator = new ProviderLocator(new ProviderRegistry());
            ProviderInfo info    = locator.GetExactly(DbPlatform.SqlServer2012);

            Assert.AreEqual("SqlServer2012Provider", info.Provider.GetType().Name);
        }
Пример #2
0
        public void TestGetExactlyThrowsIfNoMatchingProviderIsFound()
        {
            var          locator = new ProviderLocator(new ProviderFactory());
            ProviderInfo info    = locator.GetExactly(DbPlatform.SqlServer2014);

            Assert.AreEqual("SqlServer2014Provider", info.Provider.GetType().FullName);
        }
Пример #3
0
        public virtual void Setup()
        {
            _options = new MigrationOptions();
            _options.SupportedPlatforms.Set(new[] { DbPlatform }); // avoid validation errors/warnings from other providers

            // initialize IntegrationTestContext
            IProviderFactory providerFactory = new ProviderFactory();
            var          providerLocator     = new ProviderLocator(providerFactory);
            ProviderInfo providerInfo        = providerLocator.GetExactly(DbPlatform);

            IntegrationTestContext.Initialize(_options, providerInfo);
        }
Пример #4
0
        public void CheckProviderValidation(DbPlatform platformUnderExecution, DbAltererOptions options, int expectedTotalNumberOfSupportedProviders, int expectedValidationRuns)
        {
            // arrange
            var providerLocator = new ProviderLocator(new ProviderFactory());
            int totalNumberOfSupportedProviders = options.SupportedPlatforms.Sum(n => providerLocator.GetAllForMinimumRequirement(n).Count());
            var validatorFactory = new ValidatorFactory(providerLocator.GetExactly(platformUnderExecution), options, providerLocator);
            Validator validator = validatorFactory.Create();

            var reporter = A.Fake<IMigrationReporter>();
            string errors;
            string warnings;

            // act
            validator.Validate(new[] { reporter }, out errors, out warnings);

            // assert
            Assert.AreEqual(expectedTotalNumberOfSupportedProviders, totalNumberOfSupportedProviders, "Wrong total number of providers.");
            A.CallTo(() => reporter.Report(A<IMigrationContext>._)).MustHaveHappened(Repeated.Exactly.Times(expectedValidationRuns));
        }
        public SqlAggregateMigrationGenerator(Server server, Database database, GeneratorOptions options)
            : base(server, database, options)
        {
            var          providerLocator     = new ProviderLocator(new ProviderFactory()); // CLEAN: use DI container
            ProviderInfo provider            = providerLocator.GetExactly(DbPlatform.SqlServer2008);
            var          versioningTableName = new TableName(options.VersioningTableName, options.VersioningTableSchema);

            _history = new History(versioningTableName, provider.Metadata);
            IDbConnection connection = server.ConnectionContext.SqlConnectionObject;

            connection.Open();
            connection.ChangeDatabase(Database.Name); // ATTENTION: possibly has side-effects
            try
            {
                _history.Load(connection, null);
            }
            finally
            {
                connection.Close();
            }
        }
Пример #6
0
        public void TestGetExactlyThrowsIfNoMatchingProviderIsFound()
        {
            var locator = new ProviderLocator(new ProviderRegistry());

            Assert.That(() => locator.GetExactly(DbPlatform.SqlServer2014), Throws.Exception);
        }