public void SavingUpdatesNameAndEmail() { IMember sut; var provider = ScopeProvider; using (var scope = provider.CreateScope()) { var repository = CreateRepository(provider); var memberType = MemberTypeBuilder.CreateSimpleMemberType(); MemberTypeRepository.Save(memberType); var member = MemberBuilder.CreateSimpleMember(memberType, "Johnny Hefty", "*****@*****.**", "123", "hefty"); repository.Save(member); sut = repository.Get(member.Id); sut.Username = "******"; sut.Email = "*****@*****.**"; repository.Save(sut); sut = repository.Get(member.Id); Assert.That(sut.Email, Is.EqualTo("*****@*****.**")); Assert.That(sut.Username, Is.EqualTo("This is new")); } }
public void SavingPreservesPassword() { IMember sut; var provider = ScopeProvider; using (var scope = provider.CreateScope()) { var repository = CreateRepository(provider); var memberType = MemberTypeBuilder.CreateSimpleMemberType(); MemberTypeRepository.Save(memberType); var member = MemberBuilder.CreateSimpleMember(memberType, "Johnny Hefty", "*****@*****.**", "123", "hefty"); repository.Save(member); sut = repository.Get(member.Id); // When the password is null it will not overwrite what is already there. sut.RawPasswordValue = null; repository.Save(sut); sut = repository.Get(member.Id); Assert.That(sut.RawPasswordValue, Is.EqualTo("123")); } }
public void MemberHasBuiltinProperties() { var provider = ScopeProvider; using (var scope = provider.CreateScope()) { var repository = CreateRepository(provider); var memberType = MemberTypeBuilder.CreateSimpleMemberType(); MemberTypeRepository.Save(memberType); var member = MemberBuilder.CreateSimpleMember(memberType, "Johnny Hefty", "*****@*****.**", "123", "hefty"); repository.Save(member); var sut = repository.Get(member.Id); Assert.That(memberType.CompositionPropertyGroups.Count(), Is.EqualTo(2)); Assert.That(memberType.CompositionPropertyTypes.Count(), Is.EqualTo(3 + ConventionsHelper.GetStandardPropertyTypeStubs(ShortStringHelper).Count)); Assert.That(sut.Properties.Count(), Is.EqualTo(3 + ConventionsHelper.GetStandardPropertyTypeStubs(ShortStringHelper).Count)); var grp = memberType.CompositionPropertyGroups.FirstOrDefault(x => x.Name == Constants.Conventions.Member.StandardPropertiesGroupName); Assert.IsNotNull(grp); var aliases = ConventionsHelper.GetStandardPropertyTypeStubs(ShortStringHelper).Select(x => x.Key) .ToArray(); foreach (var p in memberType.CompositionPropertyTypes.Where(x => aliases.Contains(x.Alias))) { Assert.AreEqual(grp.Id, p.PropertyGroupId.Value); } } }
private IMember CreateTestMember(IMemberType memberType = null, string name = null, string email = null, string password = null, string username = null, Guid?key = null) { var provider = ScopeProvider; using (var scope = provider.CreateScope()) { var repository = CreateRepository(provider); if (memberType == null) { memberType = MemberTypeBuilder.CreateSimpleMemberType(); MemberTypeRepository.Save(memberType); } var member = MemberBuilder.CreateSimpleMember(memberType, name ?? "Johnny Hefty", email ?? "*****@*****.**", password ?? "123", username ?? "hefty", key); repository.Save(member); scope.Complete(); return(member); } }
public void Deleting_PropertyType_Removes_The_Property_From_Member() { IMemberType memberType = MemberTypeBuilder.CreateSimpleMemberType(); MemberTypeService.Save(memberType); IMember member = MemberBuilder.CreateSimpleMember(memberType, "test", "*****@*****.**", "pass", "test"); MemberService.Save(member); int initProps = member.Properties.Count; // remove a property (NOT ONE OF THE DEFAULTS) Dictionary <string, PropertyType> standardProps = ConventionsHelper.GetStandardPropertyTypeStubs(ShortStringHelper); memberType.RemovePropertyType(memberType.PropertyTypes.First(x => standardProps.ContainsKey(x.Alias) == false).Alias); MemberTypeService.Save(memberType); // re-load it from the db member = MemberService.GetById(member.Id); Assert.AreEqual(initProps - 1, member.Properties.Count); }
/// <summary> /// Setup all standard member data for test /// </summary> private Member SetupMemberTestData( out MemberSave fakeMemberData, out MemberDisplay memberDisplay, ContentSaveAction contentAction) { // arrange MemberType memberType = MemberTypeBuilder.CreateSimpleMemberType(); Member member = MemberBuilder.CreateSimpleMember(memberType, "Test Member", "*****@*****.**", "123", "test"); var memberId = 123; member.Id = memberId; // TODO: replace with builder for MemberSave and MemberDisplay fakeMemberData = new MemberSave() { Id = memberId, SortOrder = member.SortOrder, ContentTypeId = memberType.Id, Key = member.Key, Password = new ChangingPasswordModel() { Id = 456, NewPassword = member.RawPasswordValue, OldPassword = null }, Name = member.Name, Email = member.Email, Username = member.Username, PersistedContent = member, PropertyCollectionDto = new ContentPropertyCollectionDto() { }, Groups = new List <string>(), //Alias = "fakeAlias", ContentTypeAlias = member.ContentTypeAlias, Action = contentAction, Icon = "icon-document", Path = member.Path }; memberDisplay = new MemberDisplay() { Id = memberId, SortOrder = member.SortOrder, ContentTypeId = memberType.Id, Key = member.Key, Name = member.Name, Email = member.Email, Username = member.Username, //Alias = "fakeAlias", ContentTypeAlias = member.ContentTypeAlias, ContentType = new ContentTypeBasic(), ContentTypeName = member.ContentType.Name, Icon = fakeMemberData.Icon, Path = member.Path, Tabs = new List <Tab <ContentPropertyDisplay> >() { new Tab <ContentPropertyDisplay>() { Alias = "test", Id = 77, Properties = new List <ContentPropertyDisplay>() { new ContentPropertyDisplay() { Alias = "_umb_id", View = "idwithguid", Value = new [] { "123", "guid" } }, new ContentPropertyDisplay() { Alias = "_umb_doctype" }, new ContentPropertyDisplay() { Alias = "_umb_login" }, new ContentPropertyDisplay() { Alias = "_umb_email" }, new ContentPropertyDisplay() { Alias = "_umb_password" }, new ContentPropertyDisplay() { Alias = "_umb_membergroup" } } } } }; return(member); }
/// <summary> /// Setup all standard member data for test /// </summary> private Member SetupMemberTestData( out MemberSave fakeMemberData, out MemberDisplay memberDisplay, ContentSaveAction contentAction) { // arrange var memberType = MemberTypeBuilder.CreateSimpleMemberType(); var member = MemberBuilder.CreateSimpleMember(memberType, "Test Member", "*****@*****.**", "123", "test"); var memberId = 123; member.Id = memberId; // TODO: replace with builder for MemberSave and MemberDisplay fakeMemberData = new MemberSave { Id = memberId, SortOrder = member.SortOrder, ContentTypeId = memberType.Id, Key = member.Key, Password = new ChangingPasswordModel { Id = 456, NewPassword = member.RawPasswordValue, OldPassword = null }, Name = member.Name, Email = member.Email, Username = member.Username, PersistedContent = member, PropertyCollectionDto = new ContentPropertyCollectionDto(), Groups = new List <string>(), // Alias = "fakeAlias", ContentTypeAlias = member.ContentTypeAlias, Action = contentAction, Icon = "icon-document", Path = member.Path, }; memberDisplay = new MemberDisplay { Id = memberId, SortOrder = member.SortOrder, ContentTypeId = memberType.Id, Key = member.Key, Name = member.Name, Email = member.Email, Username = member.Username, // Alias = "fakeAlias", ContentTypeAlias = member.ContentTypeAlias, ContentType = new ContentTypeBasic(), ContentTypeName = member.ContentType.Name, Icon = fakeMemberData.Icon, Path = member.Path, Tabs = new List <Tab <ContentPropertyDisplay> > { new() { Alias = "test", Id = 77, Properties = new List <ContentPropertyDisplay> { new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}login" }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email" }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}password", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}failedPasswordAttempts", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}approved", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lockedOut", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLockoutDate", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLoginDate", }, new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastPasswordChangeDate", }, }, }, }, }; return(member); }