mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 17:24:14 -05:00
Object Types are getting from DacFx ObjectTypes (#1574)
* Include Object Types are getting from DacFx * All tests are passing now with excludObjectType casting * Test fix with new ExccvludeObjectType change * Added test case for the include objects types * Updated name to objectTypesDictionary and objectType getName from Display attribute * code Review updates * Removing Exclude word logic here as the options were updated on DacFx * updating the null check * DacFx vBump * code updates according to review comments
This commit is contained in:
committed by
GitHub
parent
d78ff94b31
commit
1342a8a085
@@ -589,7 +589,7 @@ FROM MissingEdgeHubInputStream'";
|
||||
UpgradeExisting = true,
|
||||
DeploymentOptions = new DeploymentOptions()
|
||||
{
|
||||
ExcludeObjectTypes = new DeploymentOptionProperty<ObjectType[]>(new[] { ObjectType.Views })
|
||||
ExcludeObjectTypes = new DeploymentOptionProperty<string[]>(new[] { Enum.GetName(ObjectType.Views) })
|
||||
}
|
||||
};
|
||||
|
||||
@@ -669,7 +669,7 @@ FROM MissingEdgeHubInputStream'";
|
||||
DatabaseName = targetDb.DatabaseName,
|
||||
DeploymentOptions = new DeploymentOptions()
|
||||
{
|
||||
ExcludeObjectTypes = new DeploymentOptionProperty<ObjectType[]>(new[] { ObjectType.Views })
|
||||
ExcludeObjectTypes = new DeploymentOptionProperty<string[]>(new[] { Enum.GetName(ObjectType.Views) })
|
||||
}
|
||||
};
|
||||
|
||||
@@ -689,7 +689,7 @@ FROM MissingEdgeHubInputStream'";
|
||||
DatabaseName = targetDb.DatabaseName,
|
||||
DeploymentOptions = new DeploymentOptions()
|
||||
{
|
||||
ExcludeObjectTypes = new DeploymentOptionProperty<ObjectType[]>(new[] { ObjectType.Views })
|
||||
ExcludeObjectTypes = new DeploymentOptionProperty<string[]>(new[] { Enum.GetName(ObjectType.Views) })
|
||||
}
|
||||
};
|
||||
|
||||
@@ -839,6 +839,33 @@ Streaming query statement contains a reference to missing output stream 'Missing
|
||||
dacfxRequestContext.VerifyAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify Object Types Dictionary items with ObjectType Enum members
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Test]
|
||||
public void ValidateObjectTypesOptionswithEnum()
|
||||
{
|
||||
DeploymentOptions options = new DeploymentOptions();
|
||||
|
||||
// Verify the object types dictionary should exists
|
||||
Assert.That(options.ObjectTypesDictionary, Is.Not.Null, "Object types dictionary is empty");
|
||||
|
||||
// Verify that the objects dictionary has all the item from Enum
|
||||
Assert.That(options.ObjectTypesDictionary.Count, Is.EqualTo(Enum.GetNames(typeof(ObjectType)).Length), @"ObjectTypesDictionary is missing these objectTypes: {0}",
|
||||
string.Join(", ", Enum.GetNames(typeof(ObjectType)).Except(options.ObjectTypesDictionary.Keys)));
|
||||
|
||||
// Verify the options in the objects dictionary exists in the ObjectType Enum
|
||||
foreach (var objTypeRow in options.ObjectTypesDictionary)
|
||||
{
|
||||
// Verify the option exists in ObjectType Enum
|
||||
Assert.That(Enum.IsDefined(typeof(ObjectType), objTypeRow.Key), Is.True, $"{objTypeRow.Key} is not an enum member");
|
||||
|
||||
// Verify the options display name exists
|
||||
Assert.That(objTypeRow.Value, Is.Not.Empty, $"Display name for the option {objTypeRow.Key} is empty");
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateStreamingJobErrors(ValidateStreamingJobResult expected, ValidateStreamingJobResult actual)
|
||||
{
|
||||
return expected.Success == actual.Success
|
||||
@@ -860,7 +887,7 @@ Streaming query statement contains a reference to missing output stream 'Missing
|
||||
|
||||
if (v.Name == nameof(DeploymentOptions.ExcludeObjectTypes))
|
||||
{
|
||||
Assert.True((defaultP as ObjectType[])?.Length == (actualP as ObjectType[])?.Length, "Number of excluded objects is different not equal");
|
||||
Assert.True((defaultP as string[])?.Length == (actualP as string[])?.Length, "Number of excluded objects is different not equal");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -79,33 +79,33 @@ END
|
||||
private DeploymentOptions GetExcludeTableValuedFunctionOptions()
|
||||
{
|
||||
var options = new DeploymentOptions();
|
||||
options.ExcludeObjectTypes = new DeploymentOptionProperty<ObjectType[]>
|
||||
options.ExcludeObjectTypes = new DeploymentOptionProperty<string[]>
|
||||
(
|
||||
new ObjectType[]{
|
||||
ObjectType.ServerTriggers,
|
||||
ObjectType.Routes,
|
||||
ObjectType.LinkedServerLogins,
|
||||
ObjectType.Endpoints,
|
||||
ObjectType.ErrorMessages,
|
||||
ObjectType.Filegroups,
|
||||
ObjectType.Files,
|
||||
ObjectType.Logins,
|
||||
ObjectType.LinkedServers,
|
||||
ObjectType.Credentials,
|
||||
ObjectType.DatabaseScopedCredentials,
|
||||
ObjectType.DatabaseEncryptionKeys,
|
||||
ObjectType.MasterKeys,
|
||||
ObjectType.DatabaseAuditSpecifications,
|
||||
ObjectType.Audits,
|
||||
ObjectType.ServerAuditSpecifications,
|
||||
ObjectType.CryptographicProviders,
|
||||
ObjectType.ServerRoles,
|
||||
ObjectType.EventSessions,
|
||||
ObjectType.DatabaseOptions,
|
||||
ObjectType.EventNotifications,
|
||||
ObjectType.ServerRoleMembership,
|
||||
ObjectType.AssemblyFiles,
|
||||
ObjectType.TableValuedFunctions, //added Functions to excluded types
|
||||
new string[]{
|
||||
Enum.GetName(ObjectType.ServerTriggers),
|
||||
Enum.GetName(ObjectType.Routes),
|
||||
Enum.GetName(ObjectType.LinkedServerLogins),
|
||||
Enum.GetName(ObjectType.Endpoints),
|
||||
Enum.GetName(ObjectType.ErrorMessages),
|
||||
Enum.GetName(ObjectType.Filegroups),
|
||||
Enum.GetName(ObjectType.Files),
|
||||
Enum.GetName(ObjectType.Logins),
|
||||
Enum.GetName(ObjectType.LinkedServers),
|
||||
Enum.GetName(ObjectType.Credentials),
|
||||
Enum.GetName(ObjectType.DatabaseScopedCredentials),
|
||||
Enum.GetName(ObjectType.DatabaseEncryptionKeys),
|
||||
Enum.GetName(ObjectType.MasterKeys),
|
||||
Enum.GetName(ObjectType.DatabaseAuditSpecifications),
|
||||
Enum.GetName(ObjectType.Audits),
|
||||
Enum.GetName(ObjectType.ServerAuditSpecifications),
|
||||
Enum.GetName(ObjectType.CryptographicProviders),
|
||||
Enum.GetName(ObjectType.ServerRoles),
|
||||
Enum.GetName(ObjectType.EventSessions),
|
||||
Enum.GetName(ObjectType.DatabaseOptions),
|
||||
Enum.GetName(ObjectType.EventNotifications),
|
||||
Enum.GetName(ObjectType.ServerRoleMembership),
|
||||
Enum.GetName(ObjectType.AssemblyFiles),
|
||||
Enum.GetName(ObjectType.TableValuedFunctions), //added Functions to excluded types
|
||||
}
|
||||
);
|
||||
return options;
|
||||
|
||||
@@ -1356,8 +1356,8 @@ WITH VALUES
|
||||
DeploymentOptions options = new DeploymentOptions();
|
||||
|
||||
// ensure that files are excluded seperate from filegroups
|
||||
Assert.True(options.ExcludeObjectTypes.Value.Contains(SqlServer.Dac.ObjectType.Files));
|
||||
Assert.False(options.ExcludeObjectTypes.Value.Contains(SqlServer.Dac.ObjectType.Filegroups));
|
||||
Assert.True(options.ExcludeObjectTypes.Value.Contains(Enum.GetName(SqlServer.Dac.ObjectType.Files)));
|
||||
Assert.False(options.ExcludeObjectTypes.Value.Contains(Enum.GetName(SqlServer.Dac.ObjectType.Filegroups)));
|
||||
|
||||
var schemaCompareParams = new SchemaCompareParams
|
||||
{
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
|
||||
|
||||
if (v.Name == nameof(DeploymentOptions.ExcludeObjectTypes))
|
||||
{
|
||||
Assert.That((defaultPValue as ObjectType[]).Length, Is.EqualTo((actualPValue as ObjectType[]).Length), $"Number of excluded objects is different; expected: {(defaultPValue as ObjectType[]).Length} actual: {(actualPValue as ObjectType[]).Length}");
|
||||
Assert.That((defaultPValue as string[]).Length, Is.EqualTo((actualPValue as string[]).Length), $"Number of excluded objects is different.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user