5
Birden çok özel durum için bir TestMethod istiyorum. Sorun, Testmethod ilk atılan istisnadan sonra durur.UnitTest ExpectedException çoklu istisnalar ile
Ben böyle bir şey yapabileceğini biliyoruz:
try
{
sAbc.ToInteger();
Assert.Fail(); // If it gets to this line, no exception was thrown
}
catch (ArgumentException) { }
Ama Aşağıdaki kod tabanını kullanmak istiyorum:
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger(); // throws an exception and stops here
sDecimal.ToInteger(); // throws theoretically a exception too...
}
Ve ben bir TestMethod oluşturmak istemiyoruz Her olası istisna bunun gibi:
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger();
}
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sDecimal.ToInteger();
}
nasıl ya-tipi çoklu istisnaları: Gerçekten özellik gerekiyorsa
sahiptir nUnit kullanılır? Bir seferde sadece bir istisna olacak. Bu mstest tarafından elde edilebilir mi? – liang