You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I received a warning for a check of "not assigned" property, it's related to #159 , but with Arg.Any<>() method
I managed to reproduce it in simpler project:
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using NSubstitute;
using NUnit.Framework;
namespace Example
{
public class MyController : Controller
{
public void Save()
{
}
}
[TestFixture]
public class UnitTest
{
private MyController TestedInstance { get; set; }
[SetUp]
public virtual void SetUp()
{
TestedInstance = new MyController();
}
[Test]
public void ReturnEmptyOkResponseAfterSaving()
{
HttpResponseBase response = null;
var controllerExecutionData = ConfigureTestedInstanceRequest((httpContext, requestContext) =>
{
response = httpContext.Response;
requestContext.RouteData.Values["action"] = nameof(TestedInstance.Save);
});
(TestedInstance as IController).Execute(controllerExecutionData);
response.DidNotReceive().StatusCode = Arg.Any<int>();
}
private RequestContext ConfigureTestedInstanceRequest(Action<HttpContextBase, RequestContext> configure)
{
var httpContextMock = Substitute.For<HttpContextBase>();
httpContextMock.Request.Form.Returns(callInfo => Substitute.For<NameValueCollection>());
httpContextMock.Request.QueryString.Returns(callInfo => Substitute.For<NameValueCollection>());
httpContextMock.Request.Headers.Returns(callInfo => Substitute.For<NameValueCollection>());
var routeDataMock = Substitute.For<RouteData>();
var requestContextMock = Substitute.For<RequestContext>();
requestContextMock.HttpContext.Returns(callInfo => httpContextMock);
requestContextMock.RouteData.Returns(callInfo => routeDataMock);
configure(httpContextMock, requestContextMock);
return requestContextMock;
}
}
}
The warning I get is: %userprofile%\Documents\Example\Example\UnitTest.cs(44,51,44,65): warning NS1004: Argument matcher used with a non-virtual member of a class.
The text was updated successfully, but these errors were encountered:
Hi @mariuszlip
Thanks for reporting. As you mentioned, it is indeed related to #159. Fix is already in review, I hope to release new version this month
Hello, I received a warning for a check of "not assigned" property, it's related to #159 , but with Arg.Any<>() method
I managed to reproduce it in simpler project:
The warning I get is:
%userprofile%\Documents\Example\Example\UnitTest.cs(44,51,44,65): warning NS1004: Argument matcher used with a non-virtual member of a class.
The text was updated successfully, but these errors were encountered: