public void Compile_ForAllFoundTutorials_Succeeds( [ValueSource(nameof(Tutorials))] Tutorial tutorial, [ValueSource(nameof(Cultures))] string culture) { CultureUtilities.WithCulture(culture, () => { var grammar = new PegParser().Parse(tutorial.GrammarText); var result = PegCompiler.Compile(grammar); Assert.That(result.Errors, Is.Empty); }); }
public void TestTimes() { CultureUtilities.ForceCulture(); var log = Logger.LogToStringBuilder(); Logger.UseTimer(new MockTimer()); Logger.Show(timestamp: true, timeDifference: true); Logger.Variable("name", "Llewellyn"); Logger.Variable("name", "Llewellyn"); Logger.Variable("name", "Llewellyn"); Approvals.Verify(log.ToString()); }
private void PopulateDropDown() { uxNameDrop.DataSource = CultureUtilities.GetCultureList(); uxNameDrop.DataTextField = "CultureName"; uxNameDrop.DataValueField = "Language-Region"; uxNameDrop.DataBind(); uxNameDrop.Items.Insert(0, new ListItem("Select Culture", "")); uxNameDrop.SelectedIndex = 0; uxDisplayNameBaseDrop.DataSource = DataAccessContext.CultureRepository.GetAll(); uxDisplayNameBaseDrop.DataTextField = "DisplayName"; uxDisplayNameBaseDrop.DataValueField = "CultureID"; uxDisplayNameBaseDrop.DataBind(); }
public void Parse_For05Calculator_ThrowsForInvalidFormats( [Values("5,7+8,9*42")] string expression, [ValueSource(nameof(Cultures))] string culture) { CultureUtilities.WithCulture(culture, () => { var tutorial = Tutorial.FindAll().Single(t => t.Name == "05 - Calculator"); var grammar = new PegParser().Parse(tutorial.GrammarText); var compiled = PegCompiler.Compile(grammar); var parser = CodeCompiler.Compile <object>(compiled); Assert.Throws <FormatException>(() => parser.Parse(expression)); }); }
public void Parse_ForAllFoundTutorials_Succeeds( [ValueSource(nameof(Tutorials))] Tutorial tutorial, [ValueSource(nameof(Cultures))] string culture) { CultureUtilities.WithCulture(culture, () => { var grammar = new PegParser().Parse(tutorial.GrammarText); var compiled = PegCompiler.Compile(grammar); var parser = CodeCompiler.Compile <object>(compiled); var result = parser.Parse(tutorial.TestText); Assert.That(result, Is.Not.Null); }); }
private static List <string> GetUserCulturesName(IEnumerable <string> userLanguages) { List <string> userCultures = new List <string>(); foreach (string language in userLanguages ?? Enumerable.Empty <string>()) { CultureInfo contextCulture = CultureUtilities.TryCreateSpecificCulture(language); if (contextCulture == null) { continue; } userCultures.Add(contextCulture.Name); } return(userCultures.Distinct().ToList()); }
public void ConcatCultureCodePartsTest(string languageCode, string localeCode, string expected) { CultureUtilities.ConcatCultureCodeParts(languageCode, localeCode).Should().Be(expected); }
public void SplitCultureCodePartsTest(string value, string expectedLanguageCode, string expectedLocaleCode) { var(languageCode, localeCode) = CultureUtilities.SplitCultureCodeParts(value); languageCode.Should().Be(expectedLanguageCode); localeCode.Should().Be(expectedLocaleCode); }
public void CleanCutureCodeThrowsTest(string value) { Action action = () => CultureUtilities.CleanCutureCode(value); action.Should().Throw <ArgumentException>(); }
public void CleanCutureCodeTest(string value, string expected) { var actual = CultureUtilities.CleanCutureCode(value); actual.Should().Be(expected); }