Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for Unity 2020 or older #126

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Tests/Runtime/Loggers/FileLoggerAssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public async Task GetLogger_DirectoryDoesNotExist_CreateDirectoryAndWriteToFile(
sut.Logger.Log(message);
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Is.EqualTo(message + Environment.NewLine));
}
Expand All @@ -86,6 +88,8 @@ public async Task GetLogger_FileExists_OverwrittenToFile()
sut.Logger.Log(message);
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Is.EqualTo(message + Environment.NewLine));
}
Expand Down Expand Up @@ -114,6 +118,8 @@ public async Task GetLogger_OutputPathIsAbsolutePath_WriteToFile()
sut.Logger.Log(message);
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Is.EqualTo(message + Environment.NewLine));

Expand All @@ -134,6 +140,8 @@ public async Task LogFormat_WriteToFile()
sut.Logger.Log(message);
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Is.EqualTo(message + Environment.NewLine + message + Environment.NewLine));
}
Expand All @@ -153,6 +161,8 @@ public async Task LogFormat_WithTimestamp_WriteTimestamp()
sut.Logger.Log(message); // using cache
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Does.Match(
"^" +
Expand All @@ -175,6 +185,8 @@ public async Task LogException_WriteToFile()
sut.Logger.LogException(exception);
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Is.EqualTo(exception + Environment.NewLine));
}
Expand All @@ -192,6 +204,8 @@ public async Task LogException_WithTimestamp_WriteTimestamp()
sut.Logger.LogException(exception);
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Does.Match("^" + TimestampRegex + ".*"));
}
Expand All @@ -212,6 +226,8 @@ public async Task ResetLoggers_ResetLogHandler()
sut.Logger.Log("After reset");
await Task.Yield();

FileLoggerAsset.ResetLoggers(); // Need dispose log handler in Unity 2020 or older.

var actual = File.ReadAllText(path);
Assert.That(actual, Is.EqualTo("After reset" + Environment.NewLine));
}
Expand Down