|
| 1 | +using GitVersion.Testing.Helpers; |
| 2 | + |
| 3 | +namespace GitVersion.Core.Tests.Helpers; |
| 4 | + |
| 5 | +[TestFixture] |
| 6 | +public class ParticipantSanitizerTests |
| 7 | +{ |
| 8 | + [TestCase("feature/1234-is-id-with-something-kebab", "feature_1234_IsIdWithSomethingKebab")] |
| 9 | + [TestCase("feature/1234-IsSomethingPascalCase", "feature_1234_IsSomethingPascalCase")] |
| 10 | + [TestCase("feature/Caps-lower-something-kebab", "feature_CapsLowerSomethingKebab")] |
| 11 | + [TestCase("feature/Caps-lower-is-kebab", "feature_CapsLowerIsKebab")] |
| 12 | + [TestCase("kebab-folder/1234-is-id-with-something-kebab", "KebabFolder_1234_IsIdWithSomethingKebab")] |
| 13 | + [TestCase("kebab-folder/1234-IsSomethingPascalCase", "KebabFolder_1234_IsSomethingPascalCase")] |
| 14 | + [TestCase("kebab-folder/Caps-lower-something-kebab", "KebabFolder_CapsLowerSomethingKebab")] |
| 15 | + [TestCase("kebab-folder/Caps-lower-is-kebab", "KebabFolder_CapsLowerIsKebab")] |
| 16 | + [TestCase("PascalCaseFolder/1234-is-id-with-something-kebab", "PascalCaseFolder_1234_IsIdWithSomethingKebab")] |
| 17 | + [TestCase("PascalCaseFolder/1234-IsSomethingPascalCase", "PascalCaseFolder_1234_IsSomethingPascalCase")] |
| 18 | + [TestCase("PascalCaseFolder/Caps-lower-something-kebab", "PascalCaseFolder_CapsLowerSomethingKebab")] |
| 19 | + [TestCase("PascalCaseFolder/Caps-lower-is-kebab", "PascalCaseFolder_CapsLowerIsKebab")] |
| 20 | + [TestCase("1234-is-id-with-something-kebab", "1234_IsIdWithSomethingKebab")] |
| 21 | + [TestCase("1234-IsSomethingPascalCase", "1234_IsSomethingPascalCase")] |
| 22 | + [TestCase("Caps-lower-something-kebab", "CapsLowerSomethingKebab")] |
| 23 | + [TestCase("Caps-lower-is-kebab", "CapsLowerIsKebab")] |
| 24 | + [TestCase("feature/all-lower-is-kebab", "feature_AllLowerIsKebab")] |
| 25 | + [TestCase("feature/24321-Upperjustoneword", "feature_24321_Upperjustoneword")] |
| 26 | + [TestCase("feature/justoneword", "feature_Justoneword")] |
| 27 | + [TestCase("feature/PascalCase", "feature_PascalCase")] |
| 28 | + [TestCase("feature/PascalCase-with-kebab", "feature_PascalCaseWithKebab")] |
| 29 | + [TestCase("feature/12414", "feature_12414")] |
| 30 | + [TestCase("feature/12414/12342-FeatureStoryTaskWithShortDescription", "feature_12414_12342_FeatureStoryTaskWithShortDescription")] |
| 31 | + [TestCase("feature/12414/12342-Short-description", "feature_12414_12342_ShortDescription")] |
| 32 | + [TestCase("feature/12414/12342-short-description", "feature_12414_12342_ShortDescription")] |
| 33 | + [TestCase("feature/12414/12342-Short-Description", "feature_12414_12342_ShortDescription")] |
| 34 | + [TestCase("release/1.0.0", "release_1.0.0")] |
| 35 | + [TestCase("releases", "releases")] |
| 36 | + [TestCase("feature", "feature")] |
| 37 | + [TestCase("feature/tfs1-Short-description", "feature_tfs1_ShortDescription")] |
| 38 | + [TestCase("feature/f2-Short-description", "feature_f2_ShortDescription")] |
| 39 | + [TestCase("feature/bug1", "feature_bug1")] |
| 40 | + [TestCase("f2", "f2")] |
| 41 | + [TestCase("feature/f2", "feature_f2")] |
| 42 | + [TestCase("feature/story2", "feature_story2")] |
| 43 | + [TestCase("master", "master")] |
| 44 | + [TestCase("develop", "develop")] |
| 45 | + [TestCase("main", "main")] |
| 46 | + public void SanitizeValidParticipant_ShouldReturnExpectedResult(string input, string expected) |
| 47 | + { |
| 48 | + var actual = ParticipantSanitizer.SanitizeParticipant(input); |
| 49 | + actual.ShouldBe(expected); |
| 50 | + } |
| 51 | + |
| 52 | + [TestCase("")] |
| 53 | + [TestCase(" ")] |
| 54 | + public void SanitizeEmptyOrWhitespaceParticipant_ShouldThrow(string value) |
| 55 | + { |
| 56 | + var exception = Should.Throw<ArgumentException>(() => ParticipantSanitizer.SanitizeParticipant(value)); |
| 57 | + exception.Message.ShouldBe("The value cannot be an empty string or composed entirely of whitespace. (Parameter 'participant')"); |
| 58 | + } |
| 59 | + |
| 60 | + [TestCase("feature/")] |
| 61 | + [TestCase("/")] |
| 62 | + public void SanitizeInvalidParticipant_ShouldThrow(string value) |
| 63 | + { |
| 64 | + var exception = Should.Throw<ArgumentException>(() => ParticipantSanitizer.SanitizeParticipant(value)); |
| 65 | + exception.Message.ShouldBe("The value cannot end with a folder separator ('/'). (Parameter 'participant')"); |
| 66 | + } |
| 67 | +} |
0 commit comments