public void When_getting_controller_attributes_then_builds_up_instance() { using (var container = new UnityContainer()) { // Arrange var someInstance = new SomeClass(); container.RegisterInstance<ISomeInterface>(someInstance); container.RegisterType<TestFilterAttribute>(new InjectionProperty("Some")); var context = new ControllerContext { Controller = new ControllerWithTypeAttribute() }; var controllerDescriptor = new ReflectedControllerDescriptor(context.Controller.GetType()); var action = context.Controller.GetType().GetMethod("MyActionMethod"); var actionDescriptor = new ReflectedActionDescriptor(action, "MyActionMethod", controllerDescriptor); var provider = new UnityFilterAttributeFilterProvider(container); // Act Filter filter = provider.GetFilters(context, actionDescriptor).Single(); // Assert TestFilterAttribute attrib = filter.Instance as TestFilterAttribute; Assert.IsNotNull(attrib); Assert.AreEqual(FilterScope.Controller, filter.Scope); Assert.AreEqual(1234, filter.Order); Assert.AreSame(someInstance, attrib.Some); } }