[Fact] public void CreatePost_ShouldCallAddOnRegistryGrain() { var postGrain = new Mock <IBlogPostRegistryGrain>(); var postId = Guid.NewGuid(); var post = new BlogPost { }; _clusterClient.Setup(c => c.GetGrain <IBlogPostRegistryGrain>(0, null)) .Returns(() => postGrain.Object); postGrain.Setup(g => g.Add(post)).Returns(() => Task.FromResult(postId)); _blogPostService.CreatePost(post).GetAwaiter().GetResult() .Should().Be(postId, "because that's what the grain returns"); _clusterClient.Verify(c => c.GetGrain <IBlogPostRegistryGrain>(0, null), Times.Once, "because we only need one instance of the grain"); postGrain.Verify(g => g.Add(post), Times.Once(), "because we only want to create it once"); }