public void RegisterGlobalFiltersRegistersHandleErrorAttribute()
        {
            // Arrange
            var globalFilterCollection = new GlobalFilterCollection();

            // Act
            FilterConfig.RegisterGlobalFilters(globalFilterCollection);

            // Assert
            Assert.True(globalFilterCollection.Any(f => f.Instance.GetType() == typeof(HandleErrorAttribute)));
        }
        public void RemoveDeletesFilterByInstance() {
            // Arrange
            var filterInstance = new object();
            var collection = new GlobalFilterCollection();
            collection.Add(filterInstance);

            // Act
            collection.Remove(filterInstance);

            // Assert
            Assert.IsFalse(collection.Any());
        }
예제 #3
0
        public void RemoveDeletesFilterByInstance()
        {
            // Arrange
            var filterInstance = new object();
            var collection     = new GlobalFilterCollection();

            collection.Add(filterInstance);

            // Act
            collection.Remove(filterInstance);

            // Assert
            Assert.IsFalse(collection.Any());
        }
예제 #4
0
 private bool Apply(ActionExecutingContext filterContext)
 {
     return(_filters.Any(f => f.Instance.GetType() == this.GetType()) ||
            filterContext.ActionDescriptor.GetCustomAttributes(typeof(AuthorizeActivityAttribute), false).Any());
 }