internal static AppConfig CreateAppConfig(IEnumerable<Tuple<string, string>> providerNamesAndTypes)
        {
            var mockEFSection = new Mock<EntityFrameworkSection>();
            mockEFSection.Setup(m => m.DefaultConnectionFactory).Returns(new DefaultConnectionFactoryElement());

            var providers = new ProviderCollection();

            foreach (var nameAndType in providerNamesAndTypes.Where(n => n.Item1 != null))
            {
                providers.AddProvider(nameAndType.Item1, nameAndType.Item2);
            }
            mockEFSection.Setup(m => m.Providers).Returns(providers);

            return new AppConfig(new ConnectionStringSettingsCollection(), null, mockEFSection.Object);
        }
Esempio n. 2
0
        internal static AppConfig CreateAppConfig(
            string invariantName = null, string typeName = null, string sqlGeneratorName = null, string spatialProviderType = null)
        {
            var mockEFSection = new Mock<EntityFrameworkSection>();
            mockEFSection.Setup(m => m.DefaultConnectionFactory).Returns(new DefaultConnectionFactoryElement());
            mockEFSection.Setup(m => m.SpatialProviderTypeName).Returns(spatialProviderType);

            var providers = new ProviderCollection();
            if (!string.IsNullOrEmpty(invariantName))
            {
                var providerElement = providers.AddProvider(invariantName, typeName);
                if (sqlGeneratorName != null)
                {
                    providerElement.SqlGeneratorElement = new MigrationSqlGeneratorElement
                                                              {
                                                                  SqlGeneratorTypeName = sqlGeneratorName
                                                              };
                }
            }
            mockEFSection.Setup(m => m.Providers).Returns(providers);

            return new AppConfig(new ConnectionStringSettingsCollection(), null, mockEFSection.Object);
        }