我想测试一下这个控制器:
[HttpGet]
public IList<Notification> GetNotificationsByCustomerAndId([FromUri] string[] name, [FromUri] int[] lastNotificationID)
{
return _storage.GetNotifications(name, lastNotificationID, _topX);
}
特别是,在这个方法中,我想测试传入输入以形成请求Url的数组是否与进入routeData.Values
的数组相同。如果对于单值参数(不是数组),它可以工作,但不能用于数组。如果我调试Values
,我只看到controller
和action
。
[TestMethod]
public void GetNotificationsByCustomerAndId_ArrayOverload_Should_Match_InputParameter_name()
{
string[] _testName = new string[] { _testCustomer, _testCustomerBis };
string Url = string.Format(
"http://www.testpincopallo.it/Notifications/GetByCustomerAndLastID/customersNotificationsInfos?name={0}&name={1}&lastNotificationID={2}&lastNotificationID={3}",
_testName[0], _testName[1],
_testNotificationID, _testNotificationIDBis);
IHttpRouteData routeData = GetRouteData(Url);
routeData.Values["name"].Should().Be(_testName);
}
当你传递数组的时候,有没有其他的方法来进行单元测试?
https://stackoverflow.com/questions/34038494
复制相似问题