using System; using System.Collections.Generic; using NUnit.Framework; using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Services; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Cache; namespace Umbraco.Tests.Cache { [TestFixture] public class CacheRefresherEventHandlerTests { [Test] public void Can_Find_All_Event_Handlers() { var testObjects = new TestObjects(null); var serviceContext = testObjects.GetServiceContextMock(); var definitions = new IEventDefinition[] { //I would test these but they are legacy events and we don't need them for deploy, when we migrate to new/better events we can wire up the check //Permission.New += PermissionNew; //Permission.Updated += PermissionUpdated; //Permission.Deleted += PermissionDeleted; //PermissionRepository.AssignedPermissions += CacheRefresherEventHandler_AssignedPermissions; new EventDefinition(null, serviceContext.ApplicationTreeService, new EventArgs(), "Deleted"), new EventDefinition(null, serviceContext.ApplicationTreeService, new EventArgs(), "Updated"), new EventDefinition(null, serviceContext.ApplicationTreeService, new EventArgs(), "New"), new EventDefinition(null, serviceContext.SectionService, new EventArgs(), "Deleted"), new EventDefinition(null, serviceContext.SectionService, new EventArgs(), "New"), new EventDefinition>(null, serviceContext.UserService, new SaveEventArgs((IUserType) null)), new EventDefinition>(null, serviceContext.UserService, new DeleteEventArgs((IUserType) null)), new EventDefinition>(null, serviceContext.UserService, new SaveEventArgs((IUser) null)), new EventDefinition>(null, serviceContext.UserService, new DeleteEventArgs((IUser) null)), new EventDefinition>(null, serviceContext.UserService, new DeleteEventArgs((IUser) null)), new EventDefinition>(null, serviceContext.LocalizationService, new SaveEventArgs((IDictionaryItem) null)), new EventDefinition>(null, serviceContext.LocalizationService, new DeleteEventArgs((IDictionaryItem) null)), new EventDefinition>(null, serviceContext.DataTypeService, new SaveEventArgs((IDataTypeDefinition) null)), new EventDefinition>(null, serviceContext.DataTypeService, new DeleteEventArgs((IDataTypeDefinition) null)), new EventDefinition>(null, serviceContext.FileService, new SaveEventArgs((Stylesheet) null)), new EventDefinition>(null, serviceContext.FileService, new DeleteEventArgs((Stylesheet) null)), new EventDefinition>(null, serviceContext.DomainService, new SaveEventArgs((IDomain) null)), new EventDefinition>(null, serviceContext.DomainService, new DeleteEventArgs((IDomain) null)), new EventDefinition>(null, serviceContext.LocalizationService, new SaveEventArgs((ILanguage) null)), new EventDefinition>(null, serviceContext.LocalizationService, new DeleteEventArgs((ILanguage) null)), new EventDefinition>(null, serviceContext.ContentTypeService, new SaveEventArgs((IContentType) null)), new EventDefinition>(null, serviceContext.ContentTypeService, new DeleteEventArgs((IContentType) null)), new EventDefinition>(null, serviceContext.ContentTypeService, new SaveEventArgs((IMediaType) null)), new EventDefinition>(null, serviceContext.ContentTypeService, new DeleteEventArgs((IMediaType) null)), new EventDefinition>(null, serviceContext.MemberTypeService, new SaveEventArgs((IMemberType) null)), new EventDefinition>(null, serviceContext.MemberTypeService, new DeleteEventArgs((IMemberType) null)), new EventDefinition>(null, serviceContext.FileService, new SaveEventArgs((ITemplate) null)), new EventDefinition>(null, serviceContext.FileService, new DeleteEventArgs((ITemplate) null)), new EventDefinition>(null, serviceContext.MacroService, new SaveEventArgs((IMacro) null)), new EventDefinition>(null, serviceContext.MacroService, new DeleteEventArgs((IMacro) null)), new EventDefinition>(null, serviceContext.MemberService, new SaveEventArgs((IMember) null)), new EventDefinition>(null, serviceContext.MemberService, new DeleteEventArgs((IMember) null)), new EventDefinition>(null, serviceContext.MemberGroupService, new SaveEventArgs((IMemberGroup) null)), new EventDefinition>(null, serviceContext.MemberGroupService, new DeleteEventArgs((IMemberGroup) null)), new EventDefinition>(null, serviceContext.MediaService, new SaveEventArgs((IMedia) null)), new EventDefinition>(null, serviceContext.MediaService, new DeleteEventArgs((IMedia) null)), new EventDefinition>(null, serviceContext.MediaService, new MoveEventArgs(new MoveEventInfo(null, "", -1)), "Moved"), new EventDefinition>(null, serviceContext.MediaService, new MoveEventArgs(new MoveEventInfo(null, "", -1)), "Trashed"), new EventDefinition(null, serviceContext.MediaService, new RecycleBinEventArgs(Guid.NewGuid(), new Dictionary>(), true)), new EventDefinition>(null, serviceContext.ContentService, new SaveEventArgs((IContent) null)), new EventDefinition>(null, serviceContext.ContentService, new DeleteEventArgs((IContent) null)), new EventDefinition>(null, serviceContext.ContentService, new CopyEventArgs(null, null, -1)), new EventDefinition>(null, serviceContext.ContentService, new MoveEventArgs(new MoveEventInfo(null, "", -1)), "Trashed"), new EventDefinition(null, serviceContext.ContentService, new RecycleBinEventArgs(Guid.NewGuid(), new Dictionary>(), true)), new EventDefinition>(null, serviceContext.ContentService, new PublishEventArgs((IContent) null), "Published"), new EventDefinition>(null, serviceContext.ContentService, new PublishEventArgs((IContent) null), "UnPublished"), new EventDefinition>(null, serviceContext.PublicAccessService, new SaveEventArgs((PublicAccessEntry) null)), new EventDefinition>(null, serviceContext.PublicAccessService, new DeleteEventArgs((PublicAccessEntry) null)), new EventDefinition>(null, serviceContext.RelationService, new SaveEventArgs((IRelationType) null)), new EventDefinition>(null, serviceContext.RelationService, new DeleteEventArgs((IRelationType) null)), new EventDefinition>(null, serviceContext.RelationService, new SaveEventArgs((IRelationType) null)), new EventDefinition>(null, serviceContext.RelationService, new DeleteEventArgs((IRelationType) null)), }; foreach (var definition in definitions) { var found = CacheRefresherComponent.FindHandler(definition); Assert.IsNotNull(found, "Couldn't find method for " + definition.EventName + " on " + definition.Sender.GetType()); } } } }