public void CreateMigration_with_default_migration_directory()
        {
            var tool          = new MyMigrationTool();
            var configuration = new Configuration();

            configuration.AddCommandLine(
                new[]
            {
                "--MigrationName=MyMigration",
                "--ContextAssembly=EntityFramework.Design.Tests.dll",
                "--ContextType=Microsoft.Data.Entity.Design.Tests.MigrationToolTest+MyContext",
                "--MigrationAssembly=EntityFramework.Design.Tests.dll",
                "--MigrationNamespace=MyNamespace"
            });

            var scaffoldedMigration = tool.CreateMigration(configuration);

            Assert.Equal("MyNamespace", scaffoldedMigration.MigrationNamespace);
            Assert.Equal("MyMigration", scaffoldedMigration.MigrationClass);
            Assert.Equal("MyContextModelSnapshot", scaffoldedMigration.SnapshotModelClass);
            Assert.True(scaffoldedMigration.MigrationFile.EndsWith("MyMigration.cs"));
            Assert.True(scaffoldedMigration.MigrationMetadataFile.EndsWith("MyMigration.Designer.cs"));
            Assert.True(scaffoldedMigration.SnapshotModelFile.EndsWith("MyContextModelSnapshot.cs"));
            Assert.True(Path.IsPathRooted(scaffoldedMigration.MigrationFile));
            Assert.True(Path.IsPathRooted(scaffoldedMigration.MigrationMetadataFile));
            Assert.True(Path.IsPathRooted(scaffoldedMigration.SnapshotModelFile));
        }
        public void CreateMigration()
        {
            var tool          = new MyMigrationTool();
            var configuration = new Configuration();

            configuration.AddCommandLine(
                new[]
            {
                "--MigrationName=MyMigration",
                "--ContextAssembly=EntityFramework.Design.Tests.dll",
                "--ContextType=Microsoft.Data.Entity.Design.Tests.MigrationToolTest+MyContext",
                "--MigrationAssembly=EntityFramework.Design.Tests.dll",
                "--MigrationNamespace=MyNamespace",
                "--MigrationDirectory=C:\\MyDirectory"
            });

            var scaffoldedMigration = tool.CreateMigration(configuration);

            Assert.Equal("MyNamespace", scaffoldedMigration.MigrationNamespace);
            Assert.Equal("MyMigration", scaffoldedMigration.MigrationClass);
            Assert.Equal("MyContextModelSnapshot", scaffoldedMigration.SnapshotModelClass);
            Assert.Equal("C:\\MyDirectory\\MyMigration.cs", scaffoldedMigration.MigrationFile);
            Assert.Equal("C:\\MyDirectory\\MyMigration.Designer.cs", scaffoldedMigration.MigrationMetadataFile);
            Assert.Equal("C:\\MyDirectory\\MyContextModelSnapshot.cs", scaffoldedMigration.SnapshotModelFile);
        }
        public void CreateMigration_throws_if_migration_name_not_specified()
        {
            var tool          = new MyMigrationTool();
            var configuration = new Configuration();

            Assert.Equal(
                Strings.MigrationNameNotSpecified,
                Assert.Throws <InvalidOperationException>(() => tool.CreateMigration(configuration)).Message);
        }
        public void CreateMigration_throws_if_migration_name_not_specified()
        {
            var tool = new MyMigrationTool();
            var configuration = new Configuration();

            Assert.Equal(
                Strings.MigrationNameNotSpecified,
                Assert.Throws<InvalidOperationException>(() => tool.CreateMigration(configuration)).Message);
        }
        public void CreateMigration_with_default_migration_directory()
        {
            var tool = new MyMigrationTool();
            var configuration = new Configuration();

            configuration.AddCommandLine(
                new[]
                    {
                        "--MigrationName=MyMigration", 
                        "--ContextAssembly=EntityFramework.Design.Tests.dll", 
                        "--ContextType=Microsoft.Data.Entity.Design.Tests.MigrationToolTest+MyContext", 
                        "--MigrationAssembly=EntityFramework.Design.Tests.dll", 
                        "--MigrationNamespace=MyNamespace"
                    });

            var scaffoldedMigration = tool.CreateMigration(configuration);

            Assert.Equal("MyNamespace", scaffoldedMigration.MigrationNamespace);
            Assert.Equal("MyMigration", scaffoldedMigration.MigrationClass);
            Assert.Equal("MyContextModelSnapshot", scaffoldedMigration.SnapshotModelClass);
            Assert.True(scaffoldedMigration.MigrationFile.EndsWith("MyMigration.cs"));
            Assert.True(scaffoldedMigration.MigrationMetadataFile.EndsWith("MyMigration.Designer.cs"));
            Assert.True(scaffoldedMigration.SnapshotModelFile.EndsWith("MyContextModelSnapshot.cs"));
            Assert.True(Path.IsPathRooted(scaffoldedMigration.MigrationFile));
            Assert.True(Path.IsPathRooted(scaffoldedMigration.MigrationMetadataFile));
            Assert.True(Path.IsPathRooted(scaffoldedMigration.SnapshotModelFile));
        }
        public void CreateMigration()
        {
            var tool = new MyMigrationTool();
            var configuration = new Configuration();

            configuration.AddCommandLine(
                new[]
                    {
                        "--MigrationName=MyMigration", 
                        "--ContextAssembly=EntityFramework.Design.Tests.dll", 
                        "--ContextType=Microsoft.Data.Entity.Design.Tests.MigrationToolTest+MyContext", 
                        "--MigrationAssembly=EntityFramework.Design.Tests.dll", 
                        "--MigrationNamespace=MyNamespace", 
                        "--MigrationDirectory=C:\\MyDirectory"
                    });

            var scaffoldedMigration = tool.CreateMigration(configuration);

            Assert.Equal("MyNamespace", scaffoldedMigration.MigrationNamespace);
            Assert.Equal("MyMigration", scaffoldedMigration.MigrationClass);
            Assert.Equal("MyContextModelSnapshot", scaffoldedMigration.SnapshotModelClass);
            Assert.Equal("C:\\MyDirectory\\MyMigration.cs", scaffoldedMigration.MigrationFile);
            Assert.Equal("C:\\MyDirectory\\MyMigration.Designer.cs", scaffoldedMigration.MigrationMetadataFile);
            Assert.Equal("C:\\MyDirectory\\MyContextModelSnapshot.cs", scaffoldedMigration.SnapshotModelFile);
        }