public void Can_get_and_set_rename_properties()
        {
            var renameProcedureOperation = new RenameProcedureOperation("N", "N'");

            Assert.Equal("N", renameProcedureOperation.Name);
            Assert.Equal("N'", renameProcedureOperation.NewName);
        }
        public void Inverse_should_produce_rename_procedure_operation()
        {
            var renameProcedureOperation
                = new RenameProcedureOperation("dbo.Foo", "dbo.Bar");

            var inverse = (RenameProcedureOperation)renameProcedureOperation.Inverse;

            Assert.Equal("dbo.Bar", inverse.Name);
            Assert.Equal("Foo", inverse.NewName);

            renameProcedureOperation = new RenameProcedureOperation("dbo.Foo", "Bar");

            inverse = (RenameProcedureOperation)renameProcedureOperation.Inverse;

            Assert.Equal("dbo.Bar", inverse.Name);
            Assert.Equal("Foo", inverse.NewName);

            renameProcedureOperation = new RenameProcedureOperation("Foo", "Bar");

            inverse = (RenameProcedureOperation)renameProcedureOperation.Inverse;

            Assert.Equal("Bar", inverse.Name);
            Assert.Equal("Foo", inverse.NewName);
        }
 protected virtual IEnumerable<MigrationStatement> Generate(RenameProcedureOperation operation)
 {
     throw new NotSupportedException("'RenameProcedureOperation' is not supported.");
 }
        /// <summary>
        /// Generates code to perform a <see cref="RenameProcedureOperation" />.
        /// </summary>
        /// <param name="renameProcedureOperation">The operation to generate code for.</param>
        /// <param name="writer">Text writer to add the generated code to.</param>
        protected virtual void Generate(RenameProcedureOperation renameProcedureOperation, IndentedTextWriter writer)
        {
            Check.NotNull(renameProcedureOperation, "renameProcedureOperation");
            Check.NotNull(writer, "writer");

            writer.Write("RenameStoredProcedure(name := ");
            writer.Write(Quote(renameProcedureOperation.Name));
            writer.Write(", newName := ");
            writer.Write(Quote(renameProcedureOperation.NewName));
            writer.WriteLine(")");
        }
        /// <summary>
        /// Generates the specified rename procedure operation.
        /// </summary>
        /// <param name="renameProcedureOperation">The rename procedure operation.</param>
        protected virtual void Generate(RenameProcedureOperation renameProcedureOperation)
        {
            Check.NotNull(renameProcedureOperation, "renameProcedureOperation");

            using (var writer = Writer())
            {
                writer.Write("EXECUTE sp_rename @objname = N'");
                writer.Write(Escape(renameProcedureOperation.Name));
                writer.Write("', @newname = N'");
                writer.Write(Escape(renameProcedureOperation.NewName));
                writer.Write("', @objtype = N'OBJECT'");

                Statement(writer);
            }
        }
 /// <summary>
 ///     Generates the specified rename procedure operation.
 /// </summary>
 /// <param name="renameProcedureOperation">The rename procedure operation.</param>
 protected virtual void Generate(RenameProcedureOperation renameProcedureOperation)
 {
 }
        public void Generate_can_output_rename_procedure_operation()
        {
            var renameProcedureOperation
                = new RenameProcedureOperation("Foo", "Bar");

            var codeGenerator = new CSharpMigrationCodeGenerator();

            var generatedMigration
                = codeGenerator.Generate(
                    "Migration",
                    new MigrationOperation[]
                        {
                            renameProcedureOperation
                        },
                    "Source",
                    "Target",
                    "Foo",
                    "Bar");

            Assert.Equal(
                @"namespace Foo
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Bar : DbMigration
    {
        public override void Up()
        {
            RenameStoredProcedure(name: ""Foo"", newName: ""Bar"");
        }
        
        public override void Down()
        {
            RenameStoredProcedure(name: ""Bar"", newName: ""Foo"");
        }
    }
}
",
                generatedMigration.UserCode);
        }
        public void Generate_can_output_rename_procedure_operation()
        {
            var renameProcedureOperation
                = new RenameProcedureOperation("Foo", "Bar");

            var codeGenerator = new VisualBasicMigrationCodeGenerator();

            var generatedMigration
                = codeGenerator.Generate(
                    "Migration",
                    new MigrationOperation[]
                        {
                            renameProcedureOperation
                        },
                    "Source",
                    "Target",
                    "Foo",
                    "Bar");

            Assert.Equal(
                @"Imports System
Imports System.Data.Entity.Migrations
Imports Microsoft.VisualBasic

Namespace Foo
    Public Partial Class Bar
        Inherits DbMigration
    
        Public Overrides Sub Up()
            RenameStoredProcedure(name := ""Foo"", newName := ""Bar"")
        End Sub
        
        Public Overrides Sub Down()
            RenameStoredProcedure(name := ""Bar"", newName := ""Foo"")
        End Sub
    End Class
End Namespace
",
                generatedMigration.UserCode);
        }