public void Should_CRUD_File_Successfully() { Events.MediaManagerEvents.Instance.MediaFileUploaded += Instance_EntityCreated; Events.MediaManagerEvents.Instance.MediaFileUpdated += Instance_EntityUpdated; Events.MediaManagerEvents.Instance.MediaFileDeleted += Instance_EntityDeleted; Events.MediaManagerEvents.Instance.MediaArchived += Instance_MediaArchived; Events.MediaManagerEvents.Instance.MediaUnarchived += Instance_MediaUnarchived; RunApiActionInTransaction( (api, session) => { category = null; var categoryTree = TestDataProvider.CreateNewCategoryTree(); category = TestDataProvider.CreateNewCategory(categoryTree); session.SaveOrUpdate(categoryTree); session.SaveOrUpdate(category); session.Flush(); Run(session, api.Media.Files.Post, api.Media.File.Get, api.Media.File.Put, api.Media.File.Delete); }); Assert.AreEqual(1, archivedMediaEventCount, "Archived media events fired count"); Assert.AreEqual(1, unarchivedMediaEventCount, "Unarchived media events fired count"); Events.MediaManagerEvents.Instance.MediaFileUploaded -= Instance_EntityCreated; Events.MediaManagerEvents.Instance.MediaFileUpdated -= Instance_EntityUpdated; Events.MediaManagerEvents.Instance.MediaFileDeleted -= Instance_EntityDeleted; Events.MediaManagerEvents.Instance.MediaArchived -= Instance_MediaArchived; Events.MediaManagerEvents.Instance.MediaUnarchived -= Instance_MediaUnarchived; }
protected override SaveServerControlWidgetModel GetCreateModel(ISession session) { var categoryTree = TestDataProvider.CreateNewCategoryTree(); var category = TestDataProvider.CreateNewCategory(categoryTree); categoryTree.AvailableFor = new List <CategoryTreeCategorizableItem> { new CategoryTreeCategorizableItem { // See Migration201502101136.cs CategorizableItem = session.Load <CategorizableItem>(new Guid("B2F05159-74AF-4B67-AEB9-36B9CC9EED57")), CategoryTree = categoryTree } }; session.SaveOrUpdate(categoryTree); session.SaveOrUpdate(category); session.Flush(); var content = TestDataProvider.CreateNewServerControlWidget(); session.SaveOrUpdate(content); session.Flush(); return(new SaveServerControlWidgetModel { Name = TestDataProvider.ProvideRandomString(MaxLength.Name), WidgetUrl = content.Url, PreviewUrl = content.PreviewUrl, IsPublished = true, PublishedOn = content.PublishedOn, PublishedByUser = content.PublishedByUser, Categories = new List <Guid> { category.Id }, Options = new List <OptionModel> { new OptionModel { DefaultValue = "1", Key = "K1", Type = OptionType.Text }, new OptionModel { DefaultValue = Guid.NewGuid().ToString(), Key = "K2", Type = OptionType.Custom, CustomTypeIdentifier = MediaManagerFolderOptionProvider.Identifier } } }); }
protected override SaveHtmlContentWidgetModel GetCreateModel(ISession session) { var categoryTree = TestDataProvider.CreateNewCategoryTree(); category = TestDataProvider.CreateNewCategory(categoryTree); categoryTree.AvailableFor = new List <CategoryTreeCategorizableItem> { new CategoryTreeCategorizableItem { // See Migration201502101136.cs CategorizableItem = session.Load <CategorizableItem>(new Guid("B2F05159-74AF-4B67-AEB9-36B9CC9EED57")), CategoryTree = categoryTree } }; session.SaveOrUpdate(categoryTree); session.SaveOrUpdate(category); session.Flush(); var widget = TestDataProvider.CreateNewHtmlContentWidget(); session.SaveOrUpdate(widget); var content = TestDataProvider.CreateNewHtmlContentWidget(); var language1 = TestDataProvider.CreateNewLanguage(); session.SaveOrUpdate(language1); var language2 = TestDataProvider.CreateNewLanguage(); session.SaveOrUpdate(language2); var assignmentId1 = Guid.NewGuid(); var assignmentId2 = Guid.NewGuid(); content.Html = string.Format("{0}{1}{3}{2}", TestDataProvider.ProvideRandomString(50), TestDataProvider.CreateChildWidgetAssignment(widget.Id, assignmentId1), TestDataProvider.ProvideRandomString(50), TestDataProvider.CreateChildWidgetAssignment(widget.Id, assignmentId2)); session.SaveOrUpdate(content); session.Flush(); return(new SaveHtmlContentWidgetModel { Name = TestDataProvider.ProvideRandomString(MaxLength.Name), IsPublished = true, PublishedOn = content.PublishedOn, PublishedByUser = content.PublishedByUser, Categories = new List <Guid>() { category.Id }, CustomCss = content.CustomCss, UseCustomCss = true, Html = content.Html, UseHtml = true, CustomJavaScript = content.CustomJs, UseCustomJavaScript = true, Options = new List <OptionModel> { new OptionModel { DefaultValue = "1", Key = "K1", Type = OptionType.Text, Translations = new List <OptionTranslationModel> { new OptionTranslationModel { LanguageId = language1.Id.ToString(), Value = "translated_lang1" }, new OptionTranslationModel { LanguageId = language2.Id.ToString(), Value = "translated_lang2" } } }, new OptionModel { DefaultValue = Guid.NewGuid().ToString(), Key = "K2", Type = OptionType.Custom, CustomTypeIdentifier = MediaManagerFolderOptionProvider.Identifier } }, ChildContentsOptionValues = new List <MultilingualChildContentOptionValuesModel> { new MultilingualChildContentOptionValuesModel { AssignmentIdentifier = assignmentId1, MultilingualOptionValues = new List <MultilingualOptionValueModel> { new MultilingualOptionValueModel { Key = "O1", Value = "V1", UseDefaultValue = false, Type = OptionType.Text, Translations = new List <OptionTranslationModel> { new OptionTranslationModel { LanguageId = language1.Id.ToString(), Value = "V1_translated_lang1" }, new OptionTranslationModel { LanguageId = language2.Id.ToString(), Value = "V1_translated_lang2" } } } } }, new MultilingualChildContentOptionValuesModel { AssignmentIdentifier = assignmentId2, MultilingualOptionValues = new List <MultilingualOptionValueModel> { new MultilingualOptionValueModel { Key = "O2", Value = Guid.NewGuid().ToString(), UseDefaultValue = false, Type = OptionType.Custom, CustomTypeIdentifier = "media-images-folder" }, new MultilingualOptionValueModel { Key = "O3", Value = Guid.NewGuid().ToString(), UseDefaultValue = true, Type = OptionType.Text } } } } }); }
protected override SavePagePropertiesModel GetCreateModel(ISession session) { var categoryTree = TestDataProvider.CreateNewCategoryTree(); var category = TestDataProvider.CreateNewCategory(categoryTree); var image = TestDataProvider.CreateNewMediaImage(); session.SaveOrUpdate(category); session.SaveOrUpdate(image); session.Flush(); session.Clear(); return(new SavePagePropertiesModel { Title = TestDataProvider.ProvideRandomString(MaxLength.Name), Tags = new[] { this.TestDataProvider.ProvideRandomString(MaxLength.Name), this.TestDataProvider.ProvideRandomString(MaxLength.Name) }, AccessRules = new[] { new AccessRuleModel { AccessLevel = AccessLevel.ReadWrite, Identity = TestDataProvider.ProvideRandomString(20), IsForRole = false }, new AccessRuleModel { AccessLevel = AccessLevel.Deny, Identity = TestDataProvider.ProvideRandomString(20), IsForRole = true } }, CustomCss = TestDataProvider.ProvideRandomString(MaxLength.Text), CustomJavaScript = TestDataProvider.ProvideRandomString(MaxLength.Text), Description = TestDataProvider.ProvideRandomString(MaxLength.Text), Categories = new List <Guid>() { category.Id }, FeaturedImageId = image.Id, IsArchived = false, IsMasterPage = false, IsPublished = true, LanguageGroupIdentifier = null, ForceAccessProtocol = ForceProtocolType.ForceHttps, LanguageId = null, LayoutId = layout != null ? layout.Id : (Guid?)null, MasterPageId = masterPage != null ? masterPage.Id : (Guid?)null, SecondaryImageId = image.Id, MainImageId = image.Id, MetaData = new MetadataModel { MetaTitle = TestDataProvider.ProvideRandomString(MaxLength.Name), MetaDescription = TestDataProvider.ProvideRandomString(MaxLength.Text), MetaKeywords = TestDataProvider.ProvideRandomString(MaxLength.Text) }, PageOptions = new List <OptionValueModel> { new OptionValueModel { DefaultValue = TestDataProvider.ProvideRandomString(100), Value = TestDataProvider.ProvideRandomString(100), Key = TestDataProvider.ProvideRandomString(100), Type = OptionType.Text, UseDefaultValue = false }, new OptionValueModel { DefaultValue = Guid.NewGuid().ToString(), Value = Guid.NewGuid().ToString(), Key = TestDataProvider.ProvideRandomString(100), Type = OptionType.Custom, CustomTypeIdentifier = MediaManagerFolderOptionProvider.Identifier, UseDefaultValue = false } }, PageUrl = string.Format("/{0}/", TestDataProvider.ProvideRandomString(200)), PublishedOn = TestDataProvider.ProvideRandomDateTime(), UseCanonicalUrl = TestDataProvider.ProvideRandomBooleanValue(), UseNoFollow = TestDataProvider.ProvideRandomBooleanValue(), UseNoIndex = TestDataProvider.ProvideRandomBooleanValue() }); }
public void Should_Insert_And_Retrieve_Category_Successfully() { var categoryTree = TestDataProvider.CreateNewCategoryTree(); RunEntityMapTestsInTransaction(TestDataProvider.CreateNewCategory(categoryTree)); }