moq check for exception c# code example Example: moq assert exception Assert.Throws<SomeException>(() => foo.Bar());