-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7701c67
commit 2d4ab20
Showing
7 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/Akka.Analyzers.Tests/Analyzers/AK1000/MustNotUseNewKeywordOnActorSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="MustNotUseNewKeywordOnActorSpecs.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2015-2023 .NET Petabridge, LLC | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
|
||
namespace Akka.Analyzers.Tests.Analyzers.AK1000; | ||
|
||
public class AkkaActorInstantiationAnalyzerTests | ||
{ | ||
[Fact] | ||
public async Task Analyzer_Should_Not_Report_Diagnostic_For_Valid_Usage() | ||
{ | ||
var testCode = @" | ||
using Akka.Actor; | ||
class MyActor : ActorBase { } | ||
class Test | ||
{ | ||
void Method() | ||
{ | ||
ActorSystem sys = ActorSystem.Create(""MySys""); | ||
Props props = Props.Create(() => new MyActor()); | ||
IActorRef realActorInstance = sys.ActorOf(props); | ||
} | ||
}"; | ||
await new CSharpAnalyzerTest<MustNotUseNewKeywordOnActorsAnalyzer, XUnitVerifier> | ||
{ | ||
TestCode = testCode, | ||
}.RunAsync().ConfigureAwait(true); | ||
} | ||
|
||
[Fact] | ||
public async Task Analyzer_Should_Report_Diagnostic_For_Invalid_Usage() | ||
{ | ||
var testCode = @" | ||
using Akka.Actor; | ||
class MyActor : ActorBase { } | ||
class Test | ||
{ | ||
void Method() | ||
{ | ||
MyActor actorInstance = new MyActor(); | ||
} | ||
}"; | ||
|
||
await new CSharpAnalyzerTest<MustNotUseNewKeywordOnActorsAnalyzer, XUnitVerifier> | ||
{ | ||
TestCode = testCode, | ||
ExpectedDiagnostics = | ||
{ | ||
// The diagnostic expected to be raised by the analyzer | ||
DiagnosticResult.CompilerError("AkkaActorInstantiation").WithSpan(10, 31, 10, 45).WithArguments("MyActor"), | ||
}, | ||
}.RunAsync().ConfigureAwait(false); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Akka.Analyzers.Tests")] |