Example #1
0
        public void Dispose_DisposesServiceScope()
        {
            var mockServiceProvider = new Mock <IServiceProvider>();
            var mockServiceScope    = new Mock <IServiceScope>();

            mockServiceScope.Setup(x => x.ServiceProvider).Returns(mockServiceProvider.Object);

            var mockServiceScopeFactory = new Mock <IServiceScopeFactory>();

            mockServiceScopeFactory
            .Setup(x => x.CreateScope())
            .Returns(mockServiceScope.Object);
            mockServiceProvider
            .Setup(x => x.GetService(typeof(IServiceScopeFactory)))
            .Returns(mockServiceScopeFactory.Object);

            // Act
            var service = new TmdbDataRefresherService(FakeOptions, FakeLogger, mockServiceProvider.Object);

            service.Dispose();

            mockServiceScope.Verify(ss => ss.Dispose(), Times.Once);
        }