C
C#14mo ago
bdcp

❔ Substitute interface property?

I have this interface:
public interface IAzureBlobStorage
{
UsersContext Users { get; }
}
public interface IAzureBlobStorage
{
UsersContext Users { get; }
}
And i'm trying to do some method chaining. But .Users is NULL, substitute doesnt overwrite that.
var azureBlobStorage = Substitute.For<IAzureBlobStorage>();

azureBlobStorage
.Users
.WithId(Arg.Any<Guid>())
.GetProfileImageOrDefault()
.Returns(Substitute.For<BlobClient>());
var azureBlobStorage = Substitute.For<IAzureBlobStorage>();

azureBlobStorage
.Users
.WithId(Arg.Any<Guid>())
.GetProfileImageOrDefault()
.Returns(Substitute.For<BlobClient>());
Any way i can make this work with NSubstitute?
3 Replies
UnrealSPh
UnrealSPh14mo ago
Maytham Fahmi
Maytham Fahmi
How to make mocked unit test for Azure Storage
As you have seen I have published 3 articles series on How to make integration test for Azure Storage. Mean
bdcp
bdcpOP14mo ago
it wasnt Azure specific, i was just mocking the interface, which is a wrapper to azure blob storage making everything an interface worked
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server