Skip to content

Commit

Permalink
Fixed issue with missing information about locale used in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Przywóski committed Oct 21, 2024
1 parent d0ad3cd commit 11c70fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions ExportViewer.Tests/HelperMethods/Html.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static string GenerateLanguageHtml(string xPath)
return document.DocumentElement.OuterHtml;
}

public static (string html, List<string> mediaFilePaths) GenerateMessagesHtml(string nodesXPath , string dateXpath = "" , string mediaXPath = "" , string dateTimeFormat = "")
public static (string html, List<string> mediaFilePaths) GenerateMessagesHtml(string nodesXPath , string dateXpath = "" , string mediaXPath = "" , string dateTimeFormat = "", string locale = "en-US")
{
var mediaFilePaths = new List<string>();
var random = new Random();
Expand Down Expand Up @@ -109,15 +109,15 @@ public static (string html, List<string> mediaFilePaths) GenerateMessagesHtml(st
}
}

CultureInfo.CurrentCulture = new CultureInfo(locale);
// Clone the current CultureInfo
CultureInfo cultureInfo = CultureInfo.CurrentCulture.Clone() as CultureInfo;
if (cultureInfo.Name == "pl-PL")
if (CultureInfo.CurrentCulture.Name == "pl-PL")
{
cultureInfo.DateTimeFormat.PMDesignator = "po południu";
cultureInfo.DateTimeFormat.AMDesignator = "rano";
CultureInfo.CurrentCulture.DateTimeFormat.PMDesignator = "po południu";
CultureInfo.CurrentCulture.DateTimeFormat.AMDesignator = "rano";
}

lastElement.TextContent = DateTime.Now.ToString(dateTimeFormat, cultureInfo);
lastElement.TextContent = DateTime.Now.ToString(dateTimeFormat, CultureInfo.CurrentCulture);

var fileName = $"messages/{Guid.NewGuid()}.jpg";
mediaFilePaths.Add(fileName);
Expand Down
2 changes: 1 addition & 1 deletion ExportViewer.Tests/HtmlParsingService_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public HtmlParsingService_Tests (ITestOutputHelper output)
/* [InlineData("div._a6-g" , "div._3-94._a6-o/div._a72d", "img._a6_o._3-96", "MMM dd, yyyy h:mm:sstt", "pl-PL")] */
public async void HtmlParsingService_ParseMessages (string nodesXPath , string dateXpath, string mediaXPath, string dateTimeFormat, string locale)
{
(string htmlString, List<string> mediaFilePaths) = HelperMethods.Html.GenerateMessagesHtml(nodesXPath , dateXpath, mediaXPath, dateTimeFormat);
(string htmlString, List<string> mediaFilePaths) = HelperMethods.Html.GenerateMessagesHtml(nodesXPath , dateXpath, mediaXPath, dateTimeFormat, locale);

string exportPath = Path.Combine(Path.GetTempPath() , Guid.NewGuid().ToString());
string fullPath = Path.Combine(exportPath , "test.html");
Expand Down

0 comments on commit 11c70fa

Please sign in to comment.