Hello Daniel, I try it but without effect. I solved this problem saving Emails before VerifyTheMappings
On Sun, Jun 16, 2013 at 3:27 PM, Daniel Nunes <daspn....@gmail.com> wrote: > You must override Equals and GetHashCode in your Entity class in order to > work. > > Em domingo, 16 de junho de 2013 10h39min50s UTC-3, Riderman Sousa escreveu: >> >> >> This error occurs whenever I use >> CheckList >> or >> CheckComponentList >> . >> >> My tests involving lists always >> fail<#13f4e456e788707d_CAGHZtrBfes5w9aMEcs6jKaP57tJW+i6To+T=k6Yo4V6uy8+vyQ@mail.gmail.com_error> >> ! >> Code >> >> My domain entities implementing IEntity and Id always generated by >> domain! >> >> public interface IEntity { Guid Id { get; } } >> public class Email : IEntity >> { >> public virtual Guid Id { get; protected set; } >> public virtual string Address { get; set; } >> public virtual string FieldName { get; set; } >> >> public Email() >> { >> Id = Guid.NewGuid(); >> } >> } >> public class Person : IEntity >> { >> public virtual Guid Id { get; protected set; } >> public virtual string Name { get; set; } >> public virtual string Nickname { get; set; } >> public virtual DateTime CreateAt { get; protected set; } >> public virtual ICollection<Email> Emails { get; protected set; } >> >> public Person() >> { >> Id = Guid.NewGuid(); >> Emails = new List<Email>(); >> CreateAt = DateTime.Now; >> } >> } >> >> My test is quite simple: >> >> [TestMethod] >> public void Person_can_have_0_or_more_**emails() >> { >> // Arrange >> >> // Act >> new PersistenceSpecification<**Perso >> n>(_session) >> .CheckProperty(p => p.Name, "Mike") >> .CheckProperty(p => p.Nickname, "mke") >> .CheckList(p => p.Emails, new List<Email>(){ >> new Email { Address = "add...@company.com", FieldName = >> "Work" } >> ,new Email { Address = "m...@gmail.com", FieldName = >> "Personal" } >> ,new Email { Address = "sec...@live.com", FieldName = >> "Secret" } >> }.ToList() , new EntityComparer()) >> .VerifyTheMappings(); // Assert >> } >> >> EntityComparer is used to differentiate between domain objects: >> >> public class EntityComparer : IEqualityComparer >> { >> public int GetHashCode(object obj) >> { >> if (obj == null) >> return 0; >> if (!(obj is IEntity)) >> return obj.GetHashCode(); >> >> return ((IEntity)obj).Id.GetHashCode(**); >> } >> >> public new bool Equals(object x, object y) >> { >> if (x == null || y == null) >> return false; >> if (!(x is IEntity) || !(y is IEntity)) >> return false; >> >> var ex = (IEntity)x; >> var ey = (IEntity)y; >> return ex.Id != Guid.Empty && ey.Id != Guid.Empty && ex.Id == ey.Id; >> } >> } >> >> Full code >> here<https://bitbucket.org/ridermansb/illustrateproblems/src/c5cd7cee4ec4c40dc628b4eaa6613d1daa050c31/CheckListTestProblem?at=default> >> . >> Error >> >> Expected 'CheckListTestProblem.Domain.**Email' but got >> 'CheckListTestProblem.Domain.**Email' at position 0 >> >> *Result StackTrace:* >> >> at >> FluentNHibernate.Testing.**Values.List2.**AssertGenericListMatches(**IEnumerable >> actualEnumerable, IEnumerable1 expectedEnumerable) >> at FluentNHibernate.Testing.**Values.List2.CheckValue(Object target) at >> FluentNHibernate.Testing.**PersistenceSpecification1.<>c*DisplayClass2.b* >> 1(Property1 p) at System.Collections.Generic.**List1.ForEach(Action1 >> action) at >> FluentNHibernate.Testing.**PersistenceSpecification1.**VerifyTheMappings(T >> first) >> at FluentNHibernate.Testing.**PersistenceSpecification`1.** >> VerifyTheMappings() >> at >> CheckListTestProblem.Test.**PersonTest.Person_can_have_0_**or_more_emails() >> in >> {...}\CheckListTestProblem\**CheckListTestProblem.Test\**PersonTest.cs:line >> 60 >> >> -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to fluent-nhibernate+unsubscr...@googlegroups.com. > To post to this group, send email to fluent-nhibernate@googlegroups.com. > Visit this group at http://groups.google.com/group/fluent-nhibernate. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at http://groups.google.com/group/fluent-nhibernate. For more options, visit https://groups.google.com/groups/opt_out.