Skip to content

Commit d00623c

Browse files
authored
apply minor improvements (#1844)
1 parent ed8eec9 commit d00623c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

test/Common/DurableTaskEndToEndTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ await TestHelpers.WaitUntilTrue(
584584
* as there are JSON (each of which has 1 EventTimestamp field), then we know that
585585
* Exceptions must have had their newlines removed.
586586
*/
587-
string[] lines = TestHelpers.WriteSafeReadAllLines(LinuxAppServiceLogger.LoggingPath);
587+
List<string> lines = TestHelpers.WriteSafeReadAllLines(LinuxAppServiceLogger.LoggingPath);
588588
int countTimeStampCols = Regex.Matches(string.Join("", lines), "\"EventTimestamp\":").Count;
589-
return lines.Length == countTimeStampCols;
589+
return lines.Count == countTimeStampCols;
590590
},
591591
conditionDescription: "Log file exists and newlines are removed from exceptions",
592592
timeout: TimeSpan.FromSeconds(65)); // enabling at least 2 file-buffer flushes (happen every 30 seconds)
@@ -644,7 +644,7 @@ await TestHelpers.WaitUntilTrue(
644644
await TestHelpers.WaitUntilTrue(
645645
predicate: () =>
646646
{
647-
string[] lines = TestHelpers.WriteSafeReadAllLines(LinuxAppServiceLogger.LoggingPath);
647+
List<string> lines = TestHelpers.WriteSafeReadAllLines(LinuxAppServiceLogger.LoggingPath);
648648
IEnumerable<JObject> jsons = lines.Select(line => JObject.Parse(line));
649649

650650
if (!jsons.All(json => TestHelpers.IsValidJSONLog(json)))

test/Common/TestHelpers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ public static bool IsValidJSONLog(JObject json)
282282
"Pid",
283283
"Tid",
284284
};
285-
List<string> keys = json.Properties().Select(p => p.Name).ToList();
285+
286286
foreach (string expectedKey in expectedKeys)
287287
{
288-
if (!keys.Contains(expectedKey))
288+
if (!json.TryGetValue(expectedKey, out _))
289289
{
290290
return false;
291291
}
@@ -299,7 +299,7 @@ public static bool IsValidJSONLog(JObject json)
299299
/// </summary>
300300
/// <param name="path">The file's path.</param>
301301
/// <returns>An array of each line in the file.</returns>
302-
public static string[] WriteSafeReadAllLines(string path)
302+
public static List<string> WriteSafeReadAllLines(string path)
303303
{
304304
/* A method like File.ReadAllLines cannot open a file that is open for writing by another process
305305
* This is due to the File.ReadAllLines not opening the process with ReadWrite permissions.
@@ -316,7 +316,7 @@ public static string[] WriteSafeReadAllLines(string path)
316316
file.Add(streamReader.ReadLine());
317317
}
318318

319-
return file.ToArray();
319+
return file;
320320
}
321321
}
322322

0 commit comments

Comments
 (0)