private void VerifyGetValidForFlag(SqlServerType serverType, ValidForFlag validForFlag) { ValidForFlag validforFlag = ServerVersionHelper.GetValidForFlag(serverType); ValidForFlag expected = validForFlag; Assert.Equal(validforFlag, expected); }
public void GetValidForFlagShouldReturnTheFlagIncludingSqlDwGivenSqlDwdatabase() { ValidForFlag validforFlag = ServerVersionHelper.GetValidForFlag(SqlServerType.AzureV12, true); ValidForFlag expected = ValidForFlag.SqlDw; Assert.Equal(validforFlag, expected); }
public void GetValidForFlagShouldReturnAllGivenUnKnownVersion() { ValidForFlag validforFlag = ServerVersionHelper.GetValidForFlag(SqlServerType.Unknown); ValidForFlag expected = ValidForFlag.All; Assert.Equal(validforFlag, expected); }
public void IsValidForShouldReturnTrueGivenSqlDwAndAll() { ValidForFlag serverValidFor = ValidForFlag.SqlDw; ValidForFlag validFor = ValidForFlag.All; bool expected = true; VerifyIsValidFor(serverValidFor, validFor, expected); }
public void IsValidForShouldReturnTrueGivenSqlDwAndNotSqlDw() { ValidForFlag serverValidFor = ValidForFlag.SqlDw; ValidForFlag validFor = ValidForFlag.NotSqlDw; bool expected = false; VerifyIsValidFor(serverValidFor, validFor, expected); }
/// <summary> /// Returns true if the filter can be apply to the given type and Server type /// </summary> /// <param name="type">Type of the querier</param> /// <param name="validForFlag">Server Type</param> /// <returns></returns> public bool CanApplyFilter(Type type, ValidForFlag validForFlag) { bool canApplyFilter = false; canApplyFilter = TypeToReverse == null || TypeToReverse == type; canApplyFilter = canApplyFilter && (ValidFor == 0 || ValidFor.HasFlag(validForFlag)); return(canApplyFilter); }
private bool ShouldFilterNode(TreeNode childNode, ValidForFlag validForFlag) { bool filterTheNode = false; SmoTreeNode smoTreeNode = childNode as SmoTreeNode; if (smoTreeNode != null) { if (!ServerVersionHelper.IsValidFor(validForFlag, smoTreeNode.ValidFor)) { filterTheNode = true; } } return(filterTheNode); }
/// <summary> /// Converts a server type to ValidForFlag /// </summary> public static ValidForFlag GetValidForFlag(SqlServerType serverType, bool isSqlDw) { ValidForFlag validforFlag = ValidForFlag.All; if (Enum.TryParse <ValidForFlag>(serverType.ToString(), out validforFlag)) { if (isSqlDw && serverType == SqlServerType.AzureV12) { validforFlag = ValidForFlag.SqlDw; } else { //TODO: not supporting SQL DW for on prem } return(validforFlag); } return(ValidForFlag.All); }
/// <summary> /// Returns true if the given valid for flag is not set or it includes the server version /// </summary> /// <param name="serverVersion">Server version</param> /// <param name="validFor">Valid for flag</param> /// <returns></returns> public static bool IsValidFor(ValidForFlag serverVersion, ValidForFlag validFor) { // If either the flag is not set or if the serverVersion has a default value of "all", allow the check // Otherwise, actually do the comparison of the flags return(validFor == ValidForFlag.None || serverVersion == ValidForFlag.All || validFor.HasFlag(serverVersion)); }
/// <summary> /// Returns true if the given valid for flag is not set or it includes the server version /// </summary> /// <param name="serverVersion">Server version</param> /// <param name="validFor">Valid for flag</param> /// <returns></returns> public static bool IsValidFor(ValidForFlag serverVersion, ValidForFlag validFor) { return(validFor == ValidForFlag.None || validFor.HasFlag(serverVersion)); }
private void VerifyIsValidFor(ValidForFlag serverValidFor, ValidForFlag validFor, bool expected) { bool actual = ServerVersionHelper.IsValidFor(serverValidFor, validFor); Assert.Equal(expected, actual); }
/// <summary> /// Returns true if the querier is valid for the given server version /// </summary> /// <param name="serverValidFor"></param> /// <returns></returns> public bool IsValidFor(ValidForFlag serverValidFor) { return(ServerVersionHelper.IsValidFor(serverValidFor, ValidFor)); }
private string GetProperyFilter(IEnumerable <NodeFilter> filters, Type querierType, ValidForFlag validForFlag) { string filter = string.Empty; if (filters != null) { var filtersToApply = filters.Where(f => f.CanApplyFilter(querierType, validForFlag)).ToList(); filter = string.Empty; if (filtersToApply.Any()) { filter = NodeFilter.ConcatProperties(filtersToApply); } } return(filter); }