Esempio n. 1
0
        /// <summary>
        /// Finds out whether two team objects have the same properties.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>True if given team have the same properties.</returns>
        public bool AreEqual(TournamentTeamsListViewModel x, TournamentTeamsListViewModel y)
        {
            var teamComparer = new TeamNameViewModelComparer();

            var result = x.TournamentId == y.TournamentId;

            if (result && x.TeamsList != null)
            {
                result &= x.TeamsList.SequenceEqual(y.TeamsList, teamComparer);
            }

            return(result);
        }
        /// <summary>
        /// Finds out whether two tournament objects have the same properties.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>True if given tournaments have the same properties.</returns>
        private bool AreEqual(TournamentApplyViewModel x, TournamentApplyViewModel y)
        {
            var teamComparer = new TeamNameViewModelComparer();

            y.Id.Should().Be(x.Id, "Id should be equal");
            y.TeamId.Should().Be(x.TeamId, "TeamId should be equal");
            y.TournamentTitle.Should().Be(x.TournamentTitle, "TournamentTitle should be equal");

            var xTeams = x.Teams.OrderBy(t => t.Id).ToList();
            var yTeams = y.Teams.OrderBy(t => t.Id).ToList();

            yTeams.Count.Should().Be(xTeams.Count, "Number of teams in collection should be equal");

            for (var i = 0; i < xTeams.Count; i++)
            {
                Assert.True(teamComparer.AreEqual(xTeams[i], yTeams[i]), "Team at position #{i} should match.");
            }

            return(true);
        }