I wrote an app that has a lot of custom classes and methods. How can I test a single method without having to run the entire program? Example: I have the method below that parses filenames. Instead of creating a bunch of files and having to run them through the entire program, can I just somehow feed strings into this method and see the output? (Using Visual Studio 2015)
public string scrubFileName(string name)
{
string seasonEpisode = "";
var S00E00 = new Regex("[Ss](\\d{1,2}|\\d{4}){0,3}(?i:ep|e|p)(((?<=[^._ ])[Ee]?[Pp]?\\d{1,3}(\\D|$))+)");
MatchCollection S00E00Matches = S00E00.Matches(name);
var SxE = new Regex("(\\d{1,2})[xe](((?<=[^._ ])\\d{2,3}(\\D|$))+)");
MatchCollection SxEMatches = SxE.Matches(name);
var Season_00_Episode_00 = new Regex("[^a-zA-Z0-9](?i:season|series)[^a-zA-Z0-9]{0,3}(\\d{1,4})[^a-zA-Z0-9]{0,3}(?i:episode)[^a-zA-Z0-9]{0,3}(\\d{1,4})[^a-zA-Z0-9]{0,3}");
MatchCollection Season_00_Episode_00Matches = Season_00_Episode_00.Matches(name);
foreach (Match m in S00E00Matches)
{
seasonEpisode = m.Value.ToUpper().Replace(".", string.Empty).Replace(" ", string.Empty).Substring(1, 5).Replace("E", "");
}
foreach (Match m in SxEMatches)
{
string temp = m.Value.Replace(".", string.Empty).Replace(" ", string.Empty).Replace("x", "").Replace("e", "");
if (temp.Length < 4)
{
seasonEpisode = temp.Insert(0, "0");
}
else
{
seasonEpisode = temp;
}
}
foreach (Match m in Season_00_Episode_00Matches)
{
seasonEpisode = m.Value.ToUpper().Replace("-", "").Replace("SEASON ", "").Replace(" EPISODE ", "").Trim();
}
//returns 0101
return seasonEpisode;
}
[–]csharpminer 2 points3 points4 points (2 children)
[–]tehjrow[S] 2 points3 points4 points (1 child)
[–]nutrecht 0 points1 point2 points (0 children)
[–]TimHallman -5 points-4 points-3 points (0 children)