Microsoft Orleans, Mock and IGrainObserver
Open
@ReubenBond is already working on this.
Since Sep 1, 2023.
question
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 13h 56m
- Merged PRs (30d)
- 351
Description
I am trying to run this test but I get an error.
[Fact]
public async Task Subscribe()
{
var cluster = new ClusterFixture().Cluster;
var grain = cluster.GrainFactory.GetGrain<INewsGrain>(String.Empty);
var observer = new Mock<INewsObserver>();
observer.Setup(x => x.NewsItemAdded(It.IsAny<NewsItem>()));
var observerRef = cluster.GrainFactory.CreateObjectReference<INewsObserver>(observer.Object);
await grain.Subscribe(observerRef);
var newsItem = new NewsItem
{
NewsId = Guid.NewGuid(),
Title = "Title",
Content = "Content",
AuthorId = Guid.NewGuid(),
PublishedDate = DateTime.Now,
Tags = ImmutableArray.Create("asd", "qwe")
};
await grain.AddNewsItem(newsItem);
observer.Verify(x => x.NewsItemAdded(It.IsAny<NewsItem>()), Times.Once);
}
Expected invocation on the mock once, but was 0 times: x => x.NewsItemAdded(It.IsAny())
await grain.AddNewsItem(newsItem); code works fine
Can you tell me what the problem might be?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.