public void EnsureProfileProperty_WhenUpdatingDisplayName_GivenUpdatedUserProfilePropertyInfo_ThenUpdatesProperty() { using (var testScope = SiteTestScope.BlankSite()) { // Arrange var site = testScope.SiteCollection; var userProfilePropertyInfo = new UserProfilePropertyInfo( ProfilePropertyName, "Test Profile Property", PropertyDataType.StringSingleValue); using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(site)) { try { // Act var userProfileHelper = injectionScope.Resolve <IUserProfilePropertyHelper>(); userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); userProfilePropertyInfo.DisplayName = "Test Profile Property Updated"; var userProfileProperty = userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); // Assert Assert.AreEqual(userProfileProperty.DisplayName, "Test Profile Property Updated"); } finally { this.TestCleanup(); } } } }
/// <summary> /// Cleans up the test data. /// </summary> public void TestCleanup() { using (var testScope = SiteTestScope.BlankSite()) { var site = testScope.SiteCollection; var userProfilePropertyInfo = new UserProfilePropertyInfo( ProfilePropertyName, "Test Profile Property", PropertyDataType.StringSingleValue); using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(site)) { // Try removing the test profile property try { var userProfileHelper = injectionScope.Resolve <IUserProfilePropertyHelper>(); userProfileHelper.RemoveProfileProperty(site, userProfilePropertyInfo); } catch (Exception) { // Do nothing } } } }
public void EnsureProfileProperty_WhenUpdatingVisibility_GivenUpdatedUserProfilePropertyInfo_ThenUpdatesProperty() { using (var testScope = SiteTestScope.BlankSite()) { // Arrange var site = testScope.SiteCollection; var userProfilePropertyInfo = new UserProfilePropertyInfo( ProfilePropertyName, "Test Profile Property", PropertyDataType.StringSingleValue); using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(site)) { try { // Act var userProfileHelper = injectionScope.Resolve <IUserProfilePropertyHelper>(); userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); userProfilePropertyInfo.IsVisibleOnEditor = true; userProfilePropertyInfo.IsVisibleOnViewer = true; userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); // Assert var profileTypeManager = userProfileHelper.GetProfileTypePropertyManager(site); var profileTypeProperty = profileTypeManager.GetPropertyByName(userProfilePropertyInfo.Name); Assert.AreEqual(profileTypeProperty.IsVisibleOnEditor, userProfilePropertyInfo.IsVisibleOnEditor); Assert.AreEqual(profileTypeProperty.IsVisibleOnViewer, userProfilePropertyInfo.IsVisibleOnViewer); } finally { this.TestCleanup(); } } } }
public void EnsureProfileProperty_WhenUpdatingSecurity_GivenUpdatedUserProfilePropertyInfo_ThenUpdatesProperty() { using (var testScope = SiteTestScope.BlankSite()) { // Arrange var site = testScope.SiteCollection; var userProfilePropertyInfo = new UserProfilePropertyInfo( ProfilePropertyName, "Test Profile Property", PropertyDataType.StringSingleValue) { IsUserEditable = true }; using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(site)) { try { // Act var userProfileHelper = injectionScope.Resolve <IUserProfilePropertyHelper>(); userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); // Make sure the default privacy value is set to private var profileSubtypeManager = userProfileHelper.GetProfileSubtypePropertyManager(site); var profileSubtypeProperty = profileSubtypeManager.GetPropertyByName(userProfilePropertyInfo.Name); Assert.AreEqual(Privacy.Private, profileSubtypeProperty.DefaultPrivacy); userProfilePropertyInfo.IsUserEditable = false; userProfilePropertyInfo.DefaultPrivacy = Privacy.Public; userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); profileSubtypeManager = userProfileHelper.GetProfileSubtypePropertyManager(site); profileSubtypeProperty = profileSubtypeManager.GetPropertyByName(userProfilePropertyInfo.Name); // Assert Assert.AreEqual(profileSubtypeProperty.IsUserEditable, userProfilePropertyInfo.IsUserEditable); Assert.AreEqual(profileSubtypeProperty.DefaultPrivacy, userProfilePropertyInfo.DefaultPrivacy); } finally { this.TestCleanup(); } } } }
public void EnsureProfileProperty_WhenMappedToTermSet_GivenUserProfilePropertyInfo_ThenMapsPropertyToTermSet() { using (var testScope = SiteTestScope.BlankSite()) { // Arrange var site = testScope.SiteCollection; var termSetInfo = new TermSetInfo(Guid.NewGuid(), TermSetName); var userProfilePropertyInfo = new UserProfilePropertyInfo( ProfilePropertyName, "Test Profile Property", PropertyDataType.StringSingleValue) { TermSetInfo = termSetInfo }; // Create term set var session = new TaxonomySession(site); var defaultSiteCollectionTermStore = session.DefaultSiteCollectionTermStore; var defaultSiteCollectionGroup = defaultSiteCollectionTermStore.GetSiteCollectionGroup(site); defaultSiteCollectionGroup.CreateTermSet(termSetInfo.Label, termSetInfo.Id); defaultSiteCollectionTermStore.CommitAll(); using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(site)) { try { // Act var userProfileHelper = injectionScope.Resolve <IUserProfilePropertyHelper>(); var userProfileProperty = userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); // Assert Assert.AreEqual(userProfileProperty.TermSet.Id, termSetInfo.Id); } finally { this.TestCleanup(); } } } }
public void EnsureProfileProperty_WhenLocalizing_GivenUserProfilePropertyInfo_ThenAddsLocalizedValues() { using (var testScope = SiteTestScope.BlankSite()) { // Arrange var site = testScope.SiteCollection; var userProfilePropertyInfo = new UserProfilePropertyInfo( ProfilePropertyName, "Test Profile Property", PropertyDataType.StringSingleValue) { Description = "Test property description" }; userProfilePropertyInfo.DisplayNameLocalized.Add(1036, "Propriété de test"); userProfilePropertyInfo.DescriptionLocalized.Add(1036, "Description propriété de test"); using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(site)) { try { // Act var userProfileHelper = injectionScope.Resolve <IUserProfilePropertyHelper>(); var userProfileProperty = userProfileHelper.EnsureProfileProperty(site, userProfilePropertyInfo); // Assert // 2 values: Default (english and french/1036) Assert.IsTrue(userProfileProperty.DisplayNameLocalized.Count == 2); Assert.IsTrue(userProfileProperty.DescriptionLocalized.Count == 2); } finally { this.TestCleanup(); } } } }