Skip to content

Can I verify Moq Mock in bUnit tests? #266

Answered by dcs3spp
dcs3spp asked this question in Q&A
Discussion options

You must be logged in to vote

Solved it....i was not adding the factory mock object to the services correctly!

 [Fact]
        public async Task Index_Page_DisposeAsync_Closes()
        {
            var _FactoryHubMock = new Mock<IHubProxyFactory>();
            var _HubProxyMock = new Mock<IHubProxy>();

            _HubProxyMock.Setup(x => x.DisposeAsync()).Returns(Task.CompletedTask).Verifiable();
            _FactoryHubMock.Setup(x => x.Create(It.IsAny<string>(), It.IsAny<JsonSerializerOptions>()))
                           .Returns(_HubProxyMock.Object).Verifiable();

            Services.AddScoped<ILogger<MotionDetectionRepository>, NullLogger<MotionDetectionRepository>>();
            Services.AddScoped<ILogger<

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@egil
Comment options

Answer selected by egil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants