Add 3 more test cases

This commit is contained in:
TSR Berry 2024-01-16 13:03:48 +01:00
parent fc7f80f1c0
commit 8e2b479a70
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2

View file

@ -141,6 +141,79 @@ public class MyClass
}
}
}
";
await Verifier.VerifyAnalyzerAsync(text).ConfigureAwait(false);
}
[Fact]
public async Task LogWithIdentifierAndMethodCall_NoDiagnostic()
{
string text = _loggerText + @"
public class MyClass
{
public void MyMethod6()
{
try
{
Console.WriteLine(""test"");
}
catch (InvalidOperationException abc)
{
Ryujinx.Common.Logging.Logger.Info?.Print(Ryujinx.Common.Logging.LogClass.Application, $""test: {abc.ToString()}"");
Console.WriteLine(""Test"");
}
}
}
";
await Verifier.VerifyAnalyzerAsync(text).ConfigureAwait(false);
}
[Fact]
public async Task LogWithMethodCallOnIdentifier_NoDiagnostic()
{
string text = _loggerText + @"
public class MyClass
{
public void MyMethod7()
{
try
{
Console.WriteLine(""test"");
}
catch (IndexOutOfRangeException mistake1)
{
string test = ""another test"";
Ryujinx.Common.Logging.Logger.Info?.Print(Ryujinx.Common.Logging.LogClass.Application, $""test: {string.Concat(mistake1, test)}"");
Console.WriteLine(""Test"");
}
}
}
";
await Verifier.VerifyAnalyzerAsync(text).ConfigureAwait(false);
}
[Fact]
public async Task LogWithPropertyOfException_NoDiagnostic()
{
string text = _loggerText + @"
public class MyClass
{
public void MyMethod8()
{
try
{
Console.WriteLine(""test"");
}
catch (ArgumentOutOfRangeException oob)
{
Ryujinx.Common.Logging.Logger.Info?.Print(Ryujinx.Common.Logging.LogClass.Application, $""test: {oob.Message}"");
Console.WriteLine(""Test"");
}
}
}
";
await Verifier.VerifyAnalyzerAsync(text).ConfigureAwait(false);