我是新來的嘲諷,但是這必須是真正的東西基本是我的思念:起訂量拋出異常的驗證
下面的測試代碼生成了異常:
預計調用上模擬至少一次,但從未執行:x => x.DeleteProducts(._ products)\ r \ n \ r \ n配置的設置:\ r \ nx => x.DeleteProducts(._ products),Times.Never \ r \ n \ r \ n已執行的調用:\ r \ nIProductRepository.DeleteProducts(System.Collections.Generic.List`1 [WebApiDemo.DataAccessLayer.Product])
我通過控制器的方法步驟和它似乎調用DeleteProducts方法...
// Arrange
IEnumerable<Product> _products = Helpers.ProductHelpers.CreateProducts(_numberProducts);
Mock<IProductRepository> _productRepository = new Mock<IProductRepository>();
_productRepository.Setup(x => x.DeleteProducts(_products));
ProductsController controller = new ProductsController(_productRepository.Object);
// Act
controller.Destroy(_productViewModels); // Destroy calls DeleteProducts
// Assert
_productRepository.Verify(x => x.DeleteProducts(_products));
我重新格式化了您的問題 - 這不是特別容易閱讀。 (Edit is pending ...) – SpaceBison