public void TestAzureRMTestCmdletWithParameterMetadataChangeAndOrderChange() { List <GenericBreakingChangeAttribute> attribs = new List <GenericBreakingChangeAttribute>(BreakingChangeAttributeHelper.GetAllBreakingChangeAttributesInType(typeof(AzureRMTestCmdletWithParameterMetadataChangeAndAGenericChange), null)); Assert.Equal(2, attribs.Count); //This gets in the weeds here a lil too much, we get two different types of attributes, we will try and cast one to each type and then check if //the messages look good on each GenericBreakingChangeAttribute genericAttrib = null; CmdletParameterBreakingChangeAttribute paramMetaAttrib = null; try { genericAttrib = (GenericBreakingChangeAttribute)attribs[0]; } catch (InvalidCastException) { try { genericAttrib = (GenericBreakingChangeAttribute)attribs[1]; } catch (InvalidCastException) { //this is an exception that should not happen, one of these should be of the type we are tryin to get Assert.False(true); } } try { paramMetaAttrib = (CmdletParameterBreakingChangeAttribute)attribs[0]; } catch (InvalidCastException) { try { paramMetaAttrib = (CmdletParameterBreakingChangeAttribute)attribs[1]; } catch (InvalidCastException) { //this is an exception that should not happen, one of these should be of the type we are tryin to get Assert.False(true); } } Assert.NotNull(genericAttrib); Assert.NotNull(paramMetaAttrib); string pat1 = @"(" + AzureRMTestCmdletWithParameterMetadataChangeAndAGenericChange.GenericChangeDesc + ")"; Regex reg1 = new Regex(pat1, RegexOptions.IgnoreCase | RegexOptions.Singleline); string pat2 = @"(The parameter : ')(.*)(' is changing')"; Regex reg2 = new Regex(pat2, RegexOptions.IgnoreCase | RegexOptions.Singleline); List <string> messages = BreakingChangeAttributeHelper.GetBreakingChangeMessagesForType(typeof(AzureRMTestCmdletWithParameterMetadataChangeAndAGenericChange)); Assert.Equal(2, messages.Count); string genericMessage = null; string paramMessage = null; if (reg1.IsMatch(messages[0])) { genericMessage = messages[0]; paramMessage = messages[1]; } else { genericMessage = messages[1]; paramMessage = messages[0]; } Assert.NotNull(genericMessage); Assert.NotNull(paramMessage); //The below check confirms that the pattterns exist in different messages Assert.False(reg1.IsMatch(paramMessage)); Assert.False(reg2.IsMatch(genericMessage)); Assert.False(genericMessage.Contains("This change will take effect on '")); Assert.True(genericMessage.Contains("The change is expected to take effect from the version")); Assert.False(genericMessage.Contains("powershell\r\n# Old")); Assert.True(genericMessage.Contains(" - Cmdlet : '" + VerbNameHolder.CmdletNameVerb + "-" + AzureRMTestCmdletWithParameterMetadataChangeAndAGenericChange.CmdletName)); Assert.False(genericMessage.Contains("Change description : ")); Assert.False(paramMessage.Contains("This change will take effect on '")); Assert.True(paramMessage.Contains(" - Cmdlet : '" + VerbNameHolder.CmdletNameVerb + "-" + AzureRMTestCmdletWithParameterMetadataChangeAndAGenericChange.CmdletName)); Assert.False(paramMessage.Contains("The change is expected to take effect from the version")); Assert.False(paramMessage.Contains("powershell\r\n# Old")); Assert.True(paramMessage.Contains("Change description : " + AzureRMTestCmdletWithParameterMetadataChangeAndAGenericChange.ParamChangeDesc)); }
public void TestForCmdletOutputTypeDropped() { List <GenericBreakingChangeAttribute> attribs = new List <GenericBreakingChangeAttribute>(BreakingChangeAttributeHelper.GetAllBreakingChangeAttributesInType(typeof(AzureRMTestCmdletWithCmdletWithOutputTypeDropped), null)); Assert.Equal(1, attribs.Count); Assert.False(attribs[0].ChangeInEfectByDateSet); Assert.False(attribs[0].DeprecateByVersionSet); string pat = @"(The output type ')(.*)(' is being deprecated without a replacement.)"; Regex reg = new Regex(pat, RegexOptions.IgnoreCase | RegexOptions.Singleline); List <string> messages = BreakingChangeAttributeHelper.GetBreakingChangeMessagesForType(typeof(AzureRMTestCmdletWithCmdletWithOutputTypeDropped)); Assert.Equal(1, messages.Count); Assert.True(reg.IsMatch(messages[0])); Assert.True(messages[0].Contains(" - Cmdlet : '" + VerbNameHolder.CmdletNameVerb + "-" + AzureRMTestCmdletWithCmdletWithOutputTypeDropped.CmdletName)); Assert.False(messages[0].Contains("This change will take effect on '")); Assert.False(messages[0].Contains("Change description : ")); Assert.False(messages[0].Contains("The change is expected to take effect from the version")); Assert.False(messages[0].Contains("powershell\r\n# Old")); }
public void TestForCmdletWithParamTypeChange() { List <GenericBreakingChangeAttribute> attribs = new List <GenericBreakingChangeAttribute>(BreakingChangeAttributeHelper.GetAllBreakingChangeAttributesInType(typeof(AzureRMTestCmdletWithParamTypeChange), null)); Assert.Equal(1, attribs.Count); Assert.False(attribs[0].ChangeInEfectByDateSet); Assert.False(attribs[0].DeprecateByVersionSet); string pat = @"(The parameter : ')(.*)(' is changing)"; string pat1 = @"(The type of the parameter is changing from ')(.*)(' to ')(.*)('.)"; Regex reg = new Regex(pat, RegexOptions.IgnoreCase | RegexOptions.Singleline); Regex reg1 = new Regex(pat1, RegexOptions.IgnoreCase | RegexOptions.Singleline); List <string> messages = BreakingChangeAttributeHelper.GetBreakingChangeMessagesForType(typeof(AzureRMTestCmdletWithParamTypeChange)); Assert.Equal(1, messages.Count); Assert.True(reg.IsMatch(messages[0])); Assert.True(reg1.IsMatch(messages[0])); Assert.True(messages[0].Contains(" - Cmdlet : '" + VerbNameHolder.CmdletNameVerb + "-" + AzureRMTestCmdletWithParamTypeChange.CmdletName)); Assert.False(messages[0].Contains("This change will take effect on '")); Assert.False(messages[0].Contains("The change is expected to take effect from the version")); Assert.False(messages[0].Contains("powershell\r\n# Old")); Assert.False(messages[0].Contains("Change description : ")); }