public void TestDelete() { //设置参数 const string cssPath = "/a/b/icon.css"; var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); var ids = new List <Guid> { id1, id2 }; const string path1 = "/a/b.jpg"; const string path2 = "/a/c.jpg"; var paths = new List <string> { Sys.GetPhysicalPath(path1), Sys.GetPhysicalPath(path2) }; const string css1 = "a"; const string css2 = "b"; var cssList = new List <string> { css1, css2 }; var icons = new List <Icon> { new Icon(id1, "", css1) { Path = path1 }, new Icon(id2, "", css2) { Path = path2 } }; //设置仓储操作 _mockIconRepository.Find(ids).Returns(icons); //删除图标 _manager.Delete(ids, cssPath); //验证 _mockIconRepository.Received().Remove(Arg.Is(icons)); _mockFileManager.Received().DeleteFiles(Arg.Is <IEnumerable <string> >(t => t.All(paths.Contains))); _mockFileManager.Received().FilePath = Sys.GetPhysicalPath(cssPath); _mockFileManager.Received().Remove(Arg.Is <IEnumerable <string> >(t => t.All(cssList.Contains))); _mockFileManager.Received().Save(); }