public void LogOutAsync_ThrowsWhenStatusCodeNotSuccessful() { //arrange SetupClient("error", HttpStatusCode.BadRequest); HttpRequestMessage logoutMsg = new HttpRequestMessage(HttpMethod.Get, "https://someuri"); _messageServiceSub.BuildLogoutMessage().Returns(logoutMsg); //act //assert Assert.ThrowsAsync(typeof(HttpRequestException), async() => { await _testedService.LogOutAsync(); }); }