Пример #1
0
        public async Task GivenEntity_AndCancellationToken_WhenCreate_ThenCollectionInsertOneAsync()
        {
            // Arrange
            var sut = new TestableMongoDbDataStorageService(
                _mockMongoClient.Object,
                _configuration);

            var entity = new TestableStorageEntity();
            var cancellationTokenSource = new CancellationTokenSource();

            // Act
            await sut.Create(
                entity,
                cancellationTokenSource.Token);

            // Assert
            _mockCollection.Verify(x => x.InsertOneAsync(
                                       It.Is <TestableStorageEntity>(y => y == entity),
                                       It.Is <InsertOneOptions>(y => y == null),
                                       It.Is <CancellationToken>(y => y == cancellationTokenSource.Token)), Times.Once);
        }