public void UserNotEqualsTeam() { var User = new UserListModel() { Id = 4, Name = "Anton" }; var Team = new TeamDetailModel() { Id = 2, Leader = User.Id, Members = new Collection <UserListModel>(), Name = "Team1" }; var UserListModel = new UserListModel() { Id = User.Id, Name = User.Name }; var TeamListModel = new TeamListModel() { Id = Team.Id, Name = Team.Name }; Team.Members.Add(User); Assert.False(User.Equals(Team)); Assert.False(Team.Equals(User)); }
public void UserEquals() { var User = new UserListModel() { Id = 4, Name = "Jozef" }; var Team = new TeamDetailModel() { Id = 1, Leader = User.Id, Members = new Collection <UserListModel>(), Name = "Testeri" }; var TheSameUser = new UserListModel() { Id = 4, Name = "Jozef" }; var TheSameTeam = new TeamDetailModel() { Id = 1, Leader = TheSameUser.Id, Members = new Collection <UserListModel>(), Name = "Testeri" }; Assert.True(User.Equals(TheSameUser)); Team.Members.Add(User); TheSameTeam.Members.Add(TheSameUser); Assert.True(User.Equals(TheSameUser)); Assert.Equal(User.GetHashCode(), User.GetHashCode()); }