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); }
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_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); }
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_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); }
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_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); }
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); }