コード例 #1
0
        public async Task ConfigureMongoDbIndexesService_Executes_Task()
        {
            var   target = CreateTarget();
            var   task   = target.StartAsync(CancellationToken.None);
            await task;

            await Task.Delay(1000);

            Assert.IsTrue(task.IsCompleted);

            await target.StopAsync(CancellationToken.None);

            VerifyInformationWasLogged(LoggerMock);

            ClientMock.Verify(s => s.GetDatabase(It.IsAny <string>(), null), Times.Once);
            DatabaseMock.Verify(
                s => s.GetCollection <User>(nameof(User), null), Times.Once);
            CollectionMock.VerifyGet(s => s.Indexes, Times.Once);
            IndexManagerMock.Verify(
                s => s.CreateOneAsync(It.IsAny <CreateIndexModel <User> >(), null, CancellationToken.None),
                Times.Once);
        }