Exemplo n.º 1
0
        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_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);
		}
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
		}
Exemplo n.º 8
0
        public void CreateCollection_PassCollectionWithOneEntry_ReturnsMembershipUserCollectionWithOneUser()
        {
            var config  = A.Fake <ILdapConfig>();
            var factory = new TestableLdapMembershipUserFactory("providername", config);

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

            A.CallTo(() => entry.Name).Returns("uniqueusername");
            entries.Add(entry);

            var result = factory.CreateCollection(entries);

            Assert.AreEqual(1, result.Count);
        }
Exemplo n.º 9
0
        public void Create_RdnAttributeSetOnEntry_ReturnsUserWithIdFromRdnAttribute()
        {
            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.ProviderUserKey);
        }
Exemplo n.º 10
0
        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 CreateCollection_PassCollectionWithOneEntry_ReturnsMembershipUserCollectionWithOneUser() {
			var config = A.Fake<ILdapConfig>();
			var factory = new TestableLdapMembershipUserFactory("providername", config);

			var entries = new EntryCollection();
			var entry = A.Fake<IEntry>();
			A.CallTo(() => entry.Name).Returns("uniqueusername");
			entries.Add(entry);

			var result = factory.CreateCollection(entries);

			Assert.AreEqual(1, result.Count);
		}
		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);
		}