public void ByAction() { var controller = new TestableController(); var actionContext = new ActionContext( new DefaultHttpContext(), new RouteData(), new ControllerActionDescriptor() { ActionName = nameof(TestableController.TestByAction), ControllerName = nameof(TestableController), ControllerTypeInfo = typeof(TestableController).GetTypeInfo() }); controller.ControllerContext = new ControllerContext(actionContext); foreach (var category in controller.TestByAction()) { Assert.Null(category.Children); } }