Exemple #1
0
        public void TestGetAllForMinimumRequirementSelectsTheLatestIfNotReachable()
        {
            var locator = new ProviderLocator(new ProviderRegistry());

            string[] providerTypeNames = locator.GetAllForMinimumRequirement(DbPlatform.SqlServer2014).Select(i => i.Provider).Select(p => p.GetType().Name).ToArray();
            CollectionAssert.AreEquivalent(new[] { "SqlServer2012Provider" }, providerTypeNames);
        }
        public void TestGetAllForMinimumRequirement()
        {
            var locator = new ProviderLocator(new ProviderFactory());

            string[] providerTypeNames = locator.GetAllForMinimumRequirement(DbPlatform.SqlServer2008).Select(i => i.Provider).Select(p => p.GetType().Name).ToArray();
            CollectionAssert.AreEquivalent(new[] { "SqlServer2008Provider", "SqlServer2012Provider" }, providerTypeNames);
        }
Exemple #3
0
        public Validator Create()
        {
            List <ProviderInfo> providerInfos = new List <ProviderInfo>();

            if (_options.Validate)
            {
                foreach (DbPlatform name in _options.SupportedPlatforms)
                {
                    providerInfos.AddRange(_providerLocator.GetAllForMinimumRequirement(name));
                }
            }
            if (!providerInfos.Any(i => i.Metadata.Platform == _providerInfo.Metadata.Platform &&
                                   i.Metadata.MajorVersion == _providerInfo.Metadata.MajorVersion &&
                                   i.Metadata.Driver == _providerInfo.Metadata.Driver))
            {
                providerInfos.Add(_providerInfo);
            }
            return(new Validator(providerInfos, _options));
        }
Exemple #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));
        }