Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller Mock return null for ActionResult other return types like int working fine #936

Closed
RajaduraiAz opened this issue Oct 9, 2019 · 2 comments

Comments

@RajaduraiAz
Copy link

I have similar work case for this stackoverflow question mocking method inside controller

[TestMethod]
public void Index()
{
// Arrange
var controller = Mock.Of(m => m.GetCheckStatus() == "Hi from Moq");

// Act
var result = controller.Index();

// Assert
Assert.IsNotNull(result);

}

public ActionResult Index()
{
return View();
}
It's return null value. But if we change Index return type int it's working fine

@stakx
Copy link
Contributor

stakx commented Oct 9, 2019

Hi @RajaduraiAz, please note that this issue tracker focuses on Moq development, i.e. on feature requests and bug report. Please don't post pure usage questions here, as we don't have the capacity to answer them all. For such questions, you have a much larger audience at e.g. Stack Overflow.

(Also, if you do post what you think is a bug, you should post a MCVE, i.e. a minimal & complete code example that can be run to reproduce the issue.)

@stakx stakx closed this as completed Oct 9, 2019
@RajaduraiAz
Copy link
Author

@stakx I think this is not usage related question. Moq return null value for Custom type but it's working defined data types like int. So only this posted here

@devlooped devlooped locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants