public void ValidateSchemaCompareOptionsDefaultAgainstDacFx() { DeploymentOptions deployOptions = new DeploymentOptions(); DacDeployOptions dacOptions = new DacDeployOptions(); System.Reflection.PropertyInfo[] deploymentOptionsProperties = deployOptions.GetType().GetProperties(); System.Reflection.PropertyInfo[] ddProperties = dacOptions.GetType().GetProperties(); // Note that DatabaseSpecification and sql cmd variables list is not present in Sqltools service - its not settable and is not used by ADS options. // TODO : update this test if the above options are added later Assert.True(deploymentOptionsProperties.Length == ddProperties.Length - 2, $"Number of properties is not same Deployment options : {deploymentOptionsProperties.Length} DacFx options : {ddProperties.Length}"); foreach (var deployOptionsProp in deploymentOptionsProperties) { var dacProp = dacOptions.GetType().GetProperty(deployOptionsProp.Name); Assert.True(dacProp != null, $"DacDeploy property not present for {deployOptionsProp.Name}"); var deployOptionsValue = deployOptionsProp.GetValue(deployOptions); var dacValue = dacProp.GetValue(dacOptions); if (deployOptionsProp.Name != "ExcludeObjectTypes") // do not compare for ExcludeObjectTypes because it will be different { Assert.True((deployOptionsValue == null && dacValue == null) || deployOptionsValue.Equals(dacValue), $"DacFx DacDeploy property not equal to Tools Service DeploymentOptions for { deployOptionsProp.Name}, SchemaCompareOptions value: {deployOptionsValue} and DacDeployOptions value: {dacValue} "); } } }
private DacDeployOptions CreateSchemaCompareOptions(DeploymentOptions deploymentOptions) { System.Reflection.PropertyInfo[] deploymentOptionsProperties = deploymentOptions.GetType().GetProperties(); DacDeployOptions dacOptions = new DacDeployOptions(); foreach (var deployOptionsProp in deploymentOptionsProperties) { var prop = dacOptions.GetType().GetProperty(deployOptionsProp.Name); if (prop != null) { prop.SetValue(dacOptions, deployOptionsProp.GetValue(deploymentOptions)); } } return(dacOptions); }
private bool OptionsEqualsDefault(SchemaCompareOptionsResult options) { DeploymentOptions defaultOpt = new DeploymentOptions(); DeploymentOptions actualOpt = options.DefaultDeploymentOptions; System.Reflection.PropertyInfo[] deploymentOptionsProperties = defaultOpt.GetType().GetProperties(); foreach (var v in deploymentOptionsProperties) { var defaultP = v.GetValue(defaultOpt); var actualP = v.GetValue(actualOpt); if (v.Name == "ExcludeObjectTypes") { Assert.True((defaultP as ObjectType[]).Length == (actualP as ObjectType[]).Length, $"Number of excluded objects is different; expected: {(defaultP as ObjectType[]).Length} actual: {(actualP as ObjectType[]).Length}"); } else { Assert.True((defaultP == null && actualP == null) || defaultP.Equals(actualP), $"Actual Property from Service is not equal to default property for { v.Name}, Actual value: {actualP} and Default value: {defaultP}"); } } return(true); }
public void ValidateSchemaCompareOptionsDefaultAgainstDacFx() { DeploymentOptions deployOptions = new DeploymentOptions(); DacDeployOptions dacOptions = new DacDeployOptions(); // Changes to match new defaults dacOptions.AllowDropBlockingAssemblies = true; dacOptions.AllowIncompatiblePlatform = true; dacOptions.DropObjectsNotInSource = true; dacOptions.DropPermissionsNotInSource = true; dacOptions.DropRoleMembersNotInSource = true; dacOptions.IgnoreKeywordCasing = false; dacOptions.IgnoreSemicolonBetweenStatements = false; dacOptions.IgnoreWhitespace = false; System.Reflection.PropertyInfo[] deploymentOptionsProperties = deployOptions.GetType().GetProperties(); System.Reflection.PropertyInfo[] ddProperties = dacOptions.GetType().GetProperties(); // Note that DatabaseSpecification and sql cmd variables list is not present in Sqltools service - its not settable and is not used by ADS options. // TODO : update this test if the above options are added later Assert.True(deploymentOptionsProperties.Length == ddProperties.Length - 2, $"Number of properties is not same Deployment options : {deploymentOptionsProperties.Length} DacFx options : {ddProperties.Length}"); foreach (var deployOptionsProp in deploymentOptionsProperties) { var dacProp = dacOptions.GetType().GetProperty(deployOptionsProp.Name); Assert.True(dacProp != null, $"DacDeploy property not present for {deployOptionsProp.Name}"); var deployOptionsValue = deployOptionsProp.GetValue(deployOptions); var dacValue = dacProp.GetValue(dacOptions); if (deployOptionsProp.Name != "ExcludeObjectTypes") // do not compare for ExcludeObjectTypes because it will be different { Assert.True((deployOptionsValue == null && dacValue == null) || deployOptionsValue.Equals(dacValue), $"DacFx DacDeploy property not equal to Tools Service DeploymentOptions for { deployOptionsProp.Name}, SchemaCompareOptions value: {deployOptionsValue} and DacDeployOptions value: {dacValue} "); } } }