public void CanGetMemberByEmailAddress() { var helper = Substitute.For <IMemberHelper>(); var memberDao = new MemberDao(helper); var firstName = "first"; var lastName = "last"; var contactPhone = "phone"; var emailAddress = "email address"; memberDao.MemberList = new List <IMember> { Substitute.For <IMember>(), Substitute.For <Member>(firstName, lastName, contactPhone, emailAddress, 2), Substitute.For <IMember>(), }; var member = memberDao.FindMembersByEmailAddress(emailAddress).Single(); Assert.NotNull(member); Assert.Equal(2, member.ID); Assert.Equal(firstName, member.FirstName); Assert.Equal(lastName, member.LastName); Assert.Equal(contactPhone, member.ContactPhone); Assert.Equal(emailAddress, member.EmailAddress); }
public void GetMemberByEmailAddressReturnsNullIfNotFound() { var helper = Substitute.For <IMemberHelper>(); var memberDao = new MemberDao(helper); var emailAddress = "email address"; memberDao.MemberList = new List <IMember> { Substitute.For <IMember>(), Substitute.For <IMember>(), }; var list = memberDao.FindMembersByEmailAddress(emailAddress); Assert.NotNull(list); // Shouldn't be null, should be an empty collection. Assert.Empty(list); }
public void GetMemberByEmailAddressReturnsEmptyCollectionIfNotFound() { IMemberHelper helper = new MemberHelper(); IMemberDAO dao = new MemberDao(helper); var firstName = "first"; var lastName = "last"; var contactPhone = "contactPhone"; var emailAddress = "emailAddress"; var member = dao.AddMember(firstName, lastName, contactPhone, emailAddress); for (int i = 0; i < 10; i++) { dao.AddMember("Test", "Test", "test phone", "test email"); } var result = dao.FindMembersByEmailAddress("*****@*****.**"); Assert.Empty(result); }
public void CanGetMemberByEmailAddress() { IMemberHelper helper = new MemberHelper(); IMemberDAO dao = new MemberDao(helper); var firstName = "first"; var lastName = "last"; var contactPhone = "contactPhone"; var emailAddress = "emailAddress"; var member = dao.AddMember(firstName, lastName, contactPhone, emailAddress); for (int i = 0; i < 10; i++) { dao.AddMember("Test", "Test", "test phone", "test email"); } var result = dao.FindMembersByEmailAddress(member.EmailAddress); var singleResult = result.Single(); // Test there should only be one result and get it. Assert.Equal(member, singleResult); }