public void Create_RdnAttributeNotSetOnEntry_ReturnsUserWithNameSetToEntryName() {
			var config = A.Fake<ILdapConfig>();
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entry = A.Fake<IEntry>();
			A.CallTo(() => entry.Name).Returns("username");

			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreEqual("username", result.UserName);
		}
		public void Create_RdnAttributeSetOnEntry_ReturnsUserWithNameFromRdnAttribute() {
			var config = A.Fake<ILdapConfig>();
			A.CallTo(() => config.Users.RdnAttribute).Returns("rdnattribute");
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entry = A.Fake<IEntry>();
			var properties = new Dictionary<string, IEnumerable>();
			properties.Add("rdnattribute", new[] { "username" });
			A.CallTo(() => entry.Properties).Returns(properties);

			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreEqual("username", result.UserName);
		}
Exemple #3
0
        public void Create_LastPasswordChangedDateAttributeSetOnEntry_ReturnsUserWithLastPasswordChangedDateFromLastPasswordChangedDateAttribute()
        {
            var config = A.Fake <ILdapConfig>();

            A.CallTo(() => config.Users.LastPasswordChangedDateAttribute).Returns("lastpasswordchangeddateattribute");
            var factory = new TestableLdapMembershipUserFactory("providername", config);

            var entry      = A.Fake <IEntry>();
            var properties = new Dictionary <string, IEnumerable>();

            properties.Add("lastpasswordchangeddateattribute", new[] { "2010-01-01" });
            A.CallTo(() => entry.Properties).Returns(properties);

            var result = (TestableLdapMembershipUser)factory.Create(entry);

            Assert.AreEqual(new DateTime(2010, 01, 01), result.LastPasswordChangedDate);
        }
Exemple #4
0
        public void Create_DescriptionAttributeSetOnEntry_ReturnsUserWithDescriptionFromDescriptionAttribute()
        {
            var config = A.Fake <ILdapConfig>();

            A.CallTo(() => config.Users.DescriptionAttribute).Returns("descriptionattribute");
            var factory = new TestableLdapMembershipUserFactory("providername", config);

            var entry      = A.Fake <IEntry>();
            var properties = new Dictionary <string, IEnumerable>();

            properties.Add("descriptionattribute", new[] { "description" });
            A.CallTo(() => entry.Properties).Returns(properties);

            var result = (TestableLdapMembershipUser)factory.Create(entry);

            Assert.AreEqual("description", result.Description);
        }
		public void Create_CreateMembershipUserFromEntry_UserGetsPropertiesFromEntry() {
			var config = A.Fake<ILdapConfig>();
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entry = A.Fake<IEntry>();
			A.CallTo(() => entry.Path).Returns("path");
			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreSame(entry.Properties, result.Properties);
		}
		public void Create_CreateMembershipUser_LastActivitiyDateSetToNow() {
			var config = A.Fake<ILdapConfig>();
			var now = DateTime.Now;
			var factory = new TestableLdapMembershipUserFactory("providername", config, now);

			var entry = A.Fake<IEntry>();
			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreEqual(now, result.LastActivitiyDate);
		}
		public void Create_CreationDateAttributeNotSetOnEntry_ReturnsUserWithLastLockoutDateSetToDefaultValue() {
			var config = A.Fake<ILdapConfig>();
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entry = A.Fake<IEntry>();

			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreEqual(DateTime.MinValue, result.LastLockoutDate);
		}
		public void Create_CreationDateAttributeSetOnEntry_ReturnsUserWithLastLockoutDateFromCreationDateAttribute() {
			var config = A.Fake<ILdapConfig>();
			A.CallTo(() => config.Users.CreationDateAttribute).Returns("creationdateattribute");
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entry = A.Fake<IEntry>();
			var properties = new Dictionary<string, IEnumerable>();
			properties.Add("creationdateattribute", new[] { "2010-01-01" });
			A.CallTo(() => entry.Properties).Returns(properties);

			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreEqual(new DateTime(2010,01,01), result.LastLockoutDate);
		}
		public void Create_DescriptionAttributeNotSetOnEntry_ReturnsUserWithDescriptionSetToDefaultValue() {
			var config = A.Fake<ILdapConfig>();
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entry = A.Fake<IEntry>();

			var result = (TestableLdapMembershipUser)factory.Create(entry);

			Assert.AreEqual(null, result.Description);
		}