Skip to content

Commit

Permalink
Fixed integration test. Add StringExtensions unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skuill committed Aug 20, 2023
1 parent f54163f commit 39a4d02
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void SearchLyric_IntegrationDynamicData_AreEqual(LyricsTestData testData)
Assert.IsNotNull(searchResult);
Assert.IsFalse(searchResult.IsEmpty());
Assert.AreEqual(ExternalProviderType.Musixmatch, searchResult.ExternalProviderType);
Assert.AreEqual(testData.LyricResultData, searchResult.LyricText);
Assert.AreEqual(testData.LyricResultData.Replace("\r\n", "\n"), searchResult.LyricText);
}

public static IEnumerable<object[]> GetTestData()
Expand Down
34 changes: 34 additions & 0 deletions Tests/LyricsScraperNET.UnitTest/Extensions/StringExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class StringExtensionsTest
[DataRow("Attack Attack!", "attack-attack!")]
[DataRow("I Swear I'll Change", "i-swear-i-ll-change")]
[DataRow("You Can't Spell Crap Without \"C\"", "you-can-t-spell-crap-without-c")]
[DataRow("", "")]
[DataRow(null, null)]
public void СonvertToDashedFormat_MultipleInputs_ShouldBeParse(string input, string expected)
{
// Act
Expand All @@ -18,5 +20,37 @@ public void СonvertToDashedFormat_MultipleInputs_ShouldBeParse(string input, st
// Assert
Assert.AreEqual(expected, actual);
}

[DataTestMethod]
[DataRow("Attack Attack!", true, "attackattack")]
[DataRow("The Devil Wears Prada", true, "devilwearsprada")]
[DataRow("You Can't Spell Crap Without 'C'", false, "youcantspellcrapwithoutc")]
[DataRow("Sound The Alarm", false, "soundthealarm")]
[DataRow("", true, "")]
[DataRow(null, true, null)]
public void StripRedundantChars_MultipleInputs_ShouldBeParse(string input, bool removeArticles, string expected)
{
// Act
var actual = StringExtensions.StripRedundantChars(input, removeArticles);

// Assert
Assert.AreEqual(expected, actual);
}


[DataTestMethod]
[DataRow("<div>test</div>", "test")]
[DataRow("This text < is for fun", "This text < is for fun")]
[DataRow(">not deleted<", ">not deleted<")]
[DataRow("", "")]
[DataRow(null, null)]
public void RemoveHtmlTags_MultipleInputs_ShouldBeParse(string input, string expected)
{
// Act
var actual = StringExtensions.RemoveHtmlTags(input);

// Assert
Assert.AreEqual(expected, actual);
}
}
}

0 comments on commit 39a4d02

Please sign in to comment.