1
이 단위 테스트를 수행하고 예외를 throw하려고 시도했지만 수행 할 수 없습니다. 제발 도와 줄 수 있습니까?ExpectedException 스텁이 작동하지 않는 TimeoutException이 발생합니다. C#
[TestMethod]
[ExpectedException(typeof(TimeoutException))]
public async Task HandleAsyncDeleteModel_WhenRepositoryFails_ThrowsException()
{
//Arrange
var token = new CancellationToken();
var deleteModel = new DeleteProcessCommand(_img, _tnt, _pro, _url);
var writeRepository = new StubIWriteRepository<Dto>()
{
DeleteIfExistsAsyncGuidGuidGuidCancellationToken = (img, tnt, pro, tkn) =>
{
throw new TimeoutException();
}
};
var Logger = new StubILogger();
var commandHandler = new CommandHandler(Logger, writeRepository, null, null, null, null, null, null);
//Act
await commandHandler.HandleAsync(deleteModel, token);
}
대신 행동을 기다리는 대신. 방법을 사용하십시오. // Act commandHandler.HandleAsync (deleteModel, token) .Wait(); 시도해보십시오. – AzzamAziz