public List <string> GetStopwords() { StopwordListParameter stopwordListParameter = StopwordListParameterParser.ParseStopwordListParameter(); LanguageParameter languageParameter = LanguageParameterParser.ParseLanguageParameter(); bool isStopwordListParameterPresent = stopwordListParameter.IsPresent; string fileName = isStopwordListParameterPresent ? stopwordListParameter.FileName : $"stopwords.{languageParameter.Language}.txt"; if (!FileSystem.File.Exists(path: fileName)) { return(new List <string>()); } if (isStopwordListParameterPresent) { DisplayOutput.WriteResourceLine( resourceIdent: "USED_STOPWORDLIST", placeholderValues: fileName); } return(FileSystem .File .ReadAllLines(path: fileName) .ToList()); }
public void StopwordListParameterParserTests_Args_has_StopwordListParameter_Without_File_Expect_IsPresent_False() { _mockEnvironment .Setup(m => m.GetCommandLineArgs()) .Returns(new[] { "-stopwordlist=" }); StopwordListParameter actual = _systemUnderTest .ParseStopwordListParameter(); Assert.NotNull(@object: actual); Assert.False(condition: actual.IsPresent); }
public void StopwordListParameterParserTests_Args_is_empty_Expect_IsPresent_False() { _mockEnvironment .Setup(expression: m => m.GetCommandLineArgs()) .Returns(value: Array.Empty <string>()); StopwordListParameter actual = _systemUnderTest .ParseStopwordListParameter(); Assert.NotNull(@object: actual); Assert.False(condition: actual.IsPresent); }
public void StopwordListParameterParserTests_Args_have_no_Dictionary_Parameter_Expect_IsPresent_False() { _mockEnvironment .Setup(expression: m => m.GetCommandLineArgs()) .Returns(value: new[] { "bla.txt" }); StopwordListParameter actual = _systemUnderTest .ParseStopwordListParameter(); Assert.NotNull(@object: actual); Assert.False(condition: actual.IsPresent); }
public void StopwordListParameterParserTests_Args_has_StopwordListParameter_With_File_bla_txt_Expect_FileName_bla_txt() { _mockEnvironment .Setup(m => m.GetCommandLineArgs()) .Returns(new[] { "-stopwordlist=bla.txt" }); StopwordListParameter actual = _systemUnderTest .ParseStopwordListParameter(); Assert.NotNull(@object: actual); Assert.Equal(expected: "bla.txt", actual: actual.FileName); }