public void CreateIndexWithOneColumn_GetValidCreateScript() { // Arrange var index = new Index<MyTable>("MyIndexName", "MyTable"); // Act index.AddColumn(m => m.MyColumn); // Assert Assert.Equal(1, index.GetUpScript().Count); Assert.Equal("CREATE INDEX MyIndexName \r\nON MyTable(MyColumn)\r\n", index.GetUpScript().First()); }
public void CreateIndexWithTwoColumns_GetValidCreateScript() { // Arrange var index = new Index("MyIndexName", "MyTable"); // Act index.AddColumn("MyColumn"); index.AddColumn("MyOtherColumn"); // Assert Assert.Equal(1, index.GetUpScript().Count); Assert.Equal(2, index.Columns.Count); Assert.Equal("CREATE INDEX MyIndexName \r\nON MyTable(MyColumn, MyOtherColumn)\r\n", index.GetUpScript().First()); }
public void TryToGetUpScriptOnIndexWithNoColumnsAdded_GetExceptionWithFaultMessage() { // Arrange var index = new Index("Name", "MyTable"); // Act & Assert var ex = Assert.Throws<InvalidOperationException>(() => index.GetUpScript()); Assert.Equal("No columns is added to index Name for table MyTable", ex.Message); }