示例#1
0
        public async Task When_InsertAssetsIsCalledWithANonExistentAsset_Expect_LoggersLogErrorMethodToBeCalled()
        {
            //2 - build mock by extension
            var mock = new List <AssetEntity>().AsQueryable().BuildMockDbSet();

            //LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter

            imDbContext.Setup(s => s.Assets).Returns(mock.Object);
            await assetRepository.InsertAssets(new List <AssetEntity> {
                new AssetEntity {
                    AssetId = 1
                }
            });

            //logger.Setup(s => s.Log<It.IsAnyType>(It.IsAny<LogLevel>(), It.IsAny<EventId>(), It.IsAny<It.IsAnyType>(), It.IsAny<Exception>(), null)).Verifiable();

            logger.Verify(f => f.Log(
                              It.IsAny <LogLevel>(),
                              It.IsAny <EventId>(),
                              It.IsAny <It.IsAnyType>(),
                              It.IsAny <Exception>(),
                              (Func <It.IsAnyType, Exception, string>)It.IsAny <object>()), Times.Once);
        }