Ejemplo n.º 1
0
        private MigrationContext ExecuteTestMigration(Predicate <string> databaseTypePredicate, params Action <IIfDatabaseExpressionRoot>[] fluentExpression)
        {
            // Arrange
            var mock = new Mock <IDbConnection>(MockBehavior.Loose);

            mock.Setup(x => x.State).Returns(ConnectionState.Open);
            var context = new MigrationContext(new SQLiteProcessor(mock.Object, null, null, new ProcessorOptions(), new SQLiteDbFactory()), new SingleAssembly(GetType().Assembly), null, "");

            var expression = new IfDatabaseExpressionRoot(context, databaseTypePredicate);

            // Act
            if (fluentExpression == null || fluentExpression.Length == 0)
            {
                expression.Create.Table("Foo").WithColumn("Id").AsInt16();
            }
            else
            {
                foreach (var action in fluentExpression)
                {
                    action(expression);
                }
            }

            return(context);
        }
Ejemplo n.º 2
0
        private IMigrationContext ExecuteTestMigration(Predicate <string> databaseTypePredicate, params Action <IIfDatabaseExpressionRoot>[] fluentExpression)
        {
            // Initialize
            var serviceProvider = ServiceCollectionExtensions.CreateServices()
                                  .ConfigureRunner(r => r.AddSQLite().WithGlobalConnectionString("No connection"))
                                  .BuildServiceProvider();
            var context = serviceProvider.GetRequiredService <IMigrationContext>();

            // Arrange
            var expression = new IfDatabaseExpressionRoot(context, databaseTypePredicate);

            // Act
            if (fluentExpression == null || fluentExpression.Length == 0)
            {
                expression.Create.Table("Foo").WithColumn("Id").AsInt16();
            }
            else
            {
                foreach (var action in fluentExpression)
                {
                    action(expression);
                }
            }

            return(context);
        }
        private MigrationContext ExecuteTestMigration(IEnumerable <string> databaseType, IQuerySchema processor, params Action <IIfDatabaseExpressionRoot>[] fluentExpression)
        {
            // Arrange

            var context = new MigrationContext(new MigrationConventions(), processor ?? new JetProcessor(null, null, null, null),
                                               GetType().Assembly);


            var expression = new IfDatabaseExpressionRoot(context, databaseType.ToArray());

            // Act
            if (fluentExpression == null || fluentExpression.Length == 0)
            {
                expression.Create.Table("Foo").WithColumn("Id").AsInt16();
            }
            else
            {
                foreach (var action in fluentExpression)
                {
                    action(expression);
                }
            }

            return(context);
        }
        private MigrationContext ExecuteTestMigration(IEnumerable <string> databaseType, IQuerySchema processor, params Action <IIfDatabaseExpressionRoot>[] fluentExpression)
        {
            // Arrange
            var mock = new Mock <IDbConnection>(MockBehavior.Loose);

            mock.Setup(x => x.State).Returns(ConnectionState.Open);
            var quoterOptions = new OptionsWrapper <QuoterOptions>(new QuoterOptions());
            var context       = new MigrationContext(
                processor ?? new SQLiteProcessor(
                    mock.Object,
                    null,
                    null,
                    new ProcessorOptions(),
                    new SQLiteDbFactory(),
                    new SQLiteQuoter(quoterOptions)),
                new SingleAssembly(GetType().Assembly),
                null,
                string.Empty);

            var expression = new IfDatabaseExpressionRoot(context, databaseType.ToArray());

            // Act
            if (fluentExpression == null || fluentExpression.Length == 0)
            {
                expression.Create.Table("Foo").WithColumn("Id").AsInt16();
            }
            else
            {
                foreach (var action in fluentExpression)
                {
                    action(expression);
                }
            }

            return(context);
        }