-1
進出口使用在C#項目的代碼預計在拋出新Excepction錯誤C# - ;使用斷言
public async Task should_not_raise_exception(Mock<IWebSocketClient> webSocket, SlackConnection slackConnection)
{
// given
var connectionInfo = new ConnectionInformation
{
WebSocket = webSocket.Object
};
await slackConnection.Initialise(connectionInfo);
var inboundMessage = new ChatMessage
{
MessageType = MessageType.Message,
User = "lalala"
};
slackConnection.OnMessageReceived += message => throw new Exception("EMPORER OF THE WORLD");
// when & then
Assert.DoesNotThrow(() => webSocket.Raise(x => x.OnMessage += null, null, inboundMessage));
}
但是,當我編譯它,這說明了大約一個錯誤;預計,有關錯誤代碼的部分是這樣的:
slackConnection.OnMessageReceived += message => throw new Exception("EMPORER OF THE WORLD");
// when & then
Assert.DoesNotThrow(() => webSocket.Raise(x => x.OnMessage += null, null, inboundMessage));
我使用框架4.6.1
檢查附加圖像
謝謝!有用 –