public void CreateExcludedObjects()
        {
            //successful creation
            ValidateTableCreation(new string[] { "dbo", "Table1" }, "dbo.Table1");
            ValidateTableCreation(new string[] { "[dbo]", "Table.1" }, "[dbo].Table.1");

            //null creation due to null name
            SchemaCompareObjectId object1 = new SchemaCompareObjectId
            {
                NameParts     = null, //null caused by this value
                SqlObjectType = "Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlTable"
            };

            var nullResult1 = SchemaCompareUtils.CreateExcludedObject(object1);

            Assert.Null(nullResult1);

            //null creation due to argumentException
            SchemaCompareObjectId object2 = new SchemaCompareObjectId
            {
                NameParts     = new string[] { "dbo", "Table1" },
                SqlObjectType = "SqlTable" // null caused by this value
            };

            var nullResult2 = SchemaCompareUtils.CreateExcludedObject(object2);

            Assert.Null(nullResult2);
        }
 internal static SchemaComparisonExcludedObjectId CreateExcludedObject(SchemaCompareObjectId sourceObj)
 {
     try
     {
         if (sourceObj == null || sourceObj.NameParts == null || string.IsNullOrEmpty(sourceObj.SqlObjectType))
         {
             return(null);
         }
         ObjectIdentifier id = new ObjectIdentifier(sourceObj.NameParts);
         SchemaComparisonExcludedObjectId excludedObjId = new SchemaComparisonExcludedObjectId(sourceObj.SqlObjectType, id);
         return(excludedObjId);
     }
     catch (ArgumentException)
     {
         return(null);
     }
 }
        private void ValidateTableCreation(string[] nameParts, string validationString)
        {
            SchemaCompareObjectId validObject1 = new SchemaCompareObjectId
            {
                NameParts     = nameParts,
                SqlObjectType = "Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlTable"
            };
            var validResult1 = SchemaCompareUtils.CreateExcludedObject(validObject1);

            Assert.NotNull(validResult1);
            Assert.Equal(validObject1.SqlObjectType, validResult1.TypeName);
            Assert.Equal(validObject1.NameParts.Length, validResult1.Identifier.Parts.Count);
            Assert.Equal(validationString, string.Join(".", validResult1.Identifier.Parts));
            for (int i = 0; i < validObject1.NameParts.Length; i++)
            {
                Assert.Equal(validObject1.NameParts[i], validResult1.Identifier.Parts[i]);
            }
        }