我想测试一下这个控制器:
[HttpGet] public IListGetNotificationsByCustomerAndId([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); }
在传递数组时,还有另一种单元测试方法吗?