I am working on a new application using Microsoft Orleans and .NET 8, and I need to add some tests. I am currently experimenting with Microsoft.Orleans.TestingHost following Unit testing with Orleans
In preparation for the tests, I have created the following fixture:
public sealed class ClusterFixture : IDisposable
{
public TestCluster Cluster { get; } = new TestClusterBuilder().Build();
public ClusterFixture() => Cluster.Deploy();
void IDisposable.Dispose() => Cluster.StopAllSilos();
}
I defined also a collection for my tests:
[CollectionDefinition(Name)]
public sealed class ClusterCollection : ICollectionFixture<ClusterFixture>
{
public const string Name = nameof(ClusterCollection);
}
My first test looks like this:
[Collection(ClusterCollection.Name)]
public class ClusterTests(ClusterFixture fixture)
{
private readonly TestCluster _cluster = fixture.Cluster;
[Fact]
public async Task Game_Name_Should_Be_Invernomuto()
{
var game = _cluster.GrainFactory.GetGrain<IGameGrain>(1);
var gameInfo = await game.GetState();
Assert.Equal(CONSTANTS.CLUSTER.GAME_NAME, gameInfo.Name);
}
}
However, I can't get the test to work:
System.ArgumentException: Could not find an implementation for interface InvernomutoGrainInterfaces.IGameGrain
at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(GrainInterfaceType interfaceType) in /_/src/Orleans.Core/Core/GrainInterfaceTypeToGrainTypeResolver.cs:line 102
What am I doing wrong?

The main problem was the missing project reference to the grains implementation in the test project...
Then I discovered that the cluster fixture was missing a proper storage configurator:
when the configurator has been added:
the test works