web api 2 call xUnit test warning

I can't figure out why, and if (and how) I should change the code.

The explanation (http://confluence.jetbrains.com/display/ReSharper/Return+value+of+pure+method+is+not+used) doesn't give me much help.

[Fact] public void OnError_ShouldLogAndReturnInternalException() {      // Arrange      const string message = "some error";      var exception = new Exception(message);      UserPasswordResetRequestRepository.           Setup(x => x.GetByToken(It.IsAny<string>())).           Throws(exception);      // Act      var response = Controller.ResetPassword(new AccountController.ResetPasswordRequest());      // Assert      Assert.IsType<ExceptionResult>(response);      Assert.Equal(((ExceptionResult)response).Exception.Message, message);      Log.Verify(x => x.ExceptionOccured(exception)); }
1 comment
Comment actions Permalink

This is an issue with the xunit plugin. It annotates the Assert.IsType method to declare it as a pure function, which is true (it doesn't change any state), but ReSharper therefore requires you to handle the return value (there's no point calling a pure function if you don't do something with the return value). However, the method is also an assertion method, so the return value isn't required for all circumstances. Here's the issue for the plugin: https://github.com/xunit/resharper-xunit/issues/69


Please sign in to leave a comment.