Beispiel #1
0
 public void GeneratorAddSingleColumnTest()
 {
     Configuration configuration = new Configuration(new[] { "-g", "addfirst_nametoUsers" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileName.Contains("AddColumn"));
     Assert.True(file_writer.FileContents.Contains("add_column"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("first_name"));
 }
Beispiel #2
0
 public void GeneratorAddReferenceColumnTest()
 {
     Configuration configuration = new Configuration(new[] { "-g", "AddUserToOrders", "User:reference" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("AddColumn_Orders_UserId"));
     Assert.True(file_writer.FileContents.Contains("add_column"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("\"name\":\"User\",\"type\":\"reference\"}]"));
     Assert.True(file_writer.FileContents.Contains("remove_column"));
     Assert.True(file_writer.FileContents.Contains("\"column\":\"UserId\""));
 }
Beispiel #3
0
 public void GeneratorAddSingleColumnTestDuplicateTo()
 {
     Configuration configuration = new Configuration(new[] { "-g", "addcustomernametoUsers" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.Null(file_writer.FileContents);
 }
Beispiel #4
0
 public void GeneratorSqlTest()
 {
     Configuration configuration = new Configuration(new[] { "-g", "SQL", "CREATE TABLE Users (ID {pk}, first_name {string} NOT NULL, price_paid {money})" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("SQL"));
     Assert.True(file_writer.FileContents.Contains("CREATE TABLE Users (ID {pk}, first_name {string} NOT NULL, price_paid {money})"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("down"));
     Assert.True(file_writer.FileContents.Contains("\"down\":\"\""));
 }
Beispiel #5
0
 public void GeneratorFileTest()
 {
     Configuration configuration = new Configuration(new[] { "-g", "File", "mysqlfile" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("File"));
     Assert.True(file_writer.FileContents.Contains("file"));
     Assert.True(file_writer.FileContents.Contains("mysqlfile"));
     Assert.True(file_writer.FileContents.Contains("up"));
 }
Beispiel #6
0
 public void GeneratorRemoveColumn()
 {
     Configuration configuration = new Configuration(new[] { "-g", "Removefirst_nameFromUsers" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileName.Contains("RemoveColumn"));
     Assert.True(file_writer.FileContents.Contains("remove_column"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("first_name"));
 }
Beispiel #7
0
 public void GeneratorDropTable()
 {
     Configuration configuration = new Configuration(new[] { "-g", "DropUsers" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileName.Contains("DropTable"));
     Assert.True(file_writer.FileContents.Contains("drop_table"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("Users"));
 }
Beispiel #8
0
 public void GeneratorDropIndexTest()
 {
     Configuration configuration = new Configuration(new[] { "-g", "removeindexfromUsers", "first_name", "last_name" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileName.Contains("RemoveIndex"));
     Assert.True(file_writer.FileContents.Contains("remove_index"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("first_name"));
     Assert.True(file_writer.FileContents.Contains("last_name"));
 }
Beispiel #9
0
 public void GeneratorChangeSingleColumnTest()
 {
     Configuration configuration = new Configuration(new[] { "-g", "ChangeUsers", "first_name:string" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileName.Contains("ChangeColumn"));
     Assert.True(file_writer.FileContents.Contains("change_column"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("first_name"));
     Assert.True(file_writer.FileContents.Contains("down"));
 }
Beispiel #10
0
 public void GeneratorAddTableNoColumnsSpecified()
 {
     Configuration configuration = new Configuration(new[] { "-g","Users" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileContents.Contains("create_table"));
     Assert.True(file_writer.FileContents.Contains("drop_table"));
     Assert.True(file_writer.FileContents.Contains("column_name_here"));
 }
Beispiel #11
0
 public void GeneratorAddTableMultipleColumn()
 {
     Configuration configuration = new Configuration(new[] { "-g", "Users", "first_name:string", "last_name:string" });
     TestFileWriter file_writer = new TestFileWriter();
     IHumpbackCommand target = new Generator(configuration, Settings, file_writer);
     target.Execute();
     Assert.True(file_writer.FileName.Contains("Users"));
     Assert.True(file_writer.FileContents.Contains("create_table"));
     Assert.True(file_writer.FileContents.Contains("up"));
     Assert.True(file_writer.FileContents.Contains("down"));
     Assert.True(file_writer.FileContents.Contains("drop_table"));
     Assert.True(file_writer.FileContents.Contains("first_name"));
     Assert.True(file_writer.FileContents.Contains("last_name"));
     Assert.True(file_writer.FileContents.Contains("timestamps"));
 }