我查看了檔案,其中有一些方法,例如Match,MatchRegex等,所以我決定改進下面的注釋陳述句并替換Regex.IsMatch為MatchRegex. 但是,我收到編譯時錯誤。我如何解決它?
它List<Product>不應該包含任何可以與以下正則運算式匹配的內容:@"<\s*([^ >] )[^>]*>.*?<\s*/\s*\1\s*>".
//actual.Products.Should().NotContain(p => Regex.IsMatch(p.Description, @"<\s*([^ >] )[^>]*>.*?<\s*/\s*\1\s*>"));
actual.Products.Should().NotContain(p =>
p.Description.Should().MatchRegex(@"<\s*([^ >] )[^>]*>.*?<\s*/\s*\1\s*>")); // compile-time error
uj5u.com熱心網友回復:
你可以試試這個:
actual.Products.Should().AllSatisfy(p =>
p.Description.Should().NotMatchRegex(@"<\s*([^ >] )[^>]*>.*?<\s*/\s*\1\s*>"));
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/514880.html
