dotnet / orleans-docs

Orleans documentation
MIT License
18 stars 57 forks source link

Unit test example doesn't work #6

Open NickLydon opened 3 years ago

NickLydon commented 3 years ago

From https://github.com/dotnet/orleans-docs/blob/master/src/docs/implementation/testing.md/#L1

    [Fact]
    public async Task SaysHelloCorrectly()
    {
        var cluster = new TestCluster();
        cluster.Deploy();

        var hello = cluster.GrainFactory.GetGrain<IHelloGrain>(Guid.NewGuid());
        var greeting = await hello.SayHello();

        cluster.StopAllSilos();

        Assert.Equal("Hello, World", greeting);
    }

TestCluster doesn't have a parameterless constructor, and it's not obvious what's needed to get it going. Should its usage be completely replaced by TestClusterBuilder?

RiskRunner0 commented 3 years ago

Hey Nick,

I was digging through the Orleans code, and I found some inspiration for this here, try this:

    [Fact]
    public async Task SaysHelloCorrectly()
    {
        var builder = new TestClusterBuilder();
        builder.Options.ServiceId = Guid.NewGuid().ToString();
        var cluster = builder.Build();
        cluster.Deploy();

        var hello = cluster.GrainFactory.GetGrain<IHelloGrain>(Guid.NewGuid());
        var greeting = await hello.SayHello();

        cluster.StopAllSilos();

        Assert.Equal("Hello, World", greeting);
    }

Looks like this is also part of the example later on, but yeah it should be up there with the SaysHelloCorrectly test too so you can actually compile and run.

Expecho commented 3 years ago

@QueenCitySmitty @ReubenBond Great, but now maybe we should remove the page https://dotnet.github.io/orleans/docs/implementation/testing.html since it contains exactly the same code but without those modifications. It seems to be a full duplicate.

RiskRunner0 commented 3 years ago

@Expecho Good callout, I'll put out a PR in the docs

RiskRunner0 commented 3 years ago

@Expecho here it is, take a quick look. Thanks!

Expecho commented 3 years ago

@QueenCitySmitty looks fine to me, thanks!

Expecho commented 3 years ago

@QueenCitySmitty found another issue with the docs, see https://github.com/dotnet/orleans-docs/pull/47