in SampleTests/TestCreateIndexOperationalPropsModifier.cs [88:126]
public void TestOperationalOptions()
{
int iteration = 0;
// Given no online option, do not expect script to contain ONLINE
RunTestAndVerifyResult(new DacDeployOptions(),
deployScript => Assert.IsFalse(deployScript.Contains("WITH (ONLINE ="), "Expected no ONLINE option to be set"),
iteration++);
// Given invalid option value, expect no ONLINE setting
DacDeployOptions options = SetCreateIndexContributorOptions("INVALID", null);
RunTestAndVerifyResult(options,
deployScript => Assert.IsFalse(deployScript.Contains("WITH (ONLINE ="), "Expected no ONLINE option to be set"),
iteration++);
// Given online option ON, expect deployment script to contain "ONLINE=ON"
options = SetCreateIndexContributorOptions("ON", null);
RunTestAndVerifyResult(options,
deployScript => Assert.IsTrue(deployScript.Contains("WITH (ONLINE = ON)"), "Expected ONLINE option to be 'ON'"),
iteration++);
// Given online option OFF, expect deployment script to contain "ONLINE=OFF"
options = SetCreateIndexContributorOptions("OFF", null);
RunTestAndVerifyResult(options,
deployScript => Assert.IsTrue(deployScript.Contains("WITH (ONLINE = OFF)"), "Expected ONLINE option to be 'OFF'"),
iteration++);
// Given MAXDOP option specified, expect it to be included in the settings
options = SetCreateIndexContributorOptions(null, "3");
RunTestAndVerifyResult(options,
deployScript => Assert.IsTrue(deployScript.Contains("WITH (MAXDOP = 3)"), "Expected MAXDOP option to be 'ON'"),
iteration++);
// Given MAXDOP and ONLINE option specified, expect both to be included in the settings
options = SetCreateIndexContributorOptions("OFF", "2");
RunTestAndVerifyResult(options,
deployScript => Assert.IsTrue(deployScript.Contains("WITH (ONLINE = OFF, MAXDOP = 2)"), "Expected both options to be defined"),
iteration++);
}