Esempio n. 1
0
        public void Verify_Who_Won_THe_Elections()
        {
            var clujPoll = new SortingAndSearching.SortingAndSearching.Polls
            {
                elections = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Iohannis",
                        votes     = 10
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Macovei",
                        votes     = 9
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Ponta",
                        votes     = 8
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Tariceanu",
                        votes     = 7
                    }
                }
            };

            var timisPoll = new SortingAndSearching.SortingAndSearching.Polls
            {
                elections = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Ponta",
                        votes     = 11
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Iohannis",
                        votes     = 9
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Tariceanu",
                        votes     = 3
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Macovei",
                        votes     = 2
                    }
                }
            };

            var albaPoll = new SortingAndSearching.SortingAndSearching.Polls
            {
                elections = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Iohannis",
                        votes     = 13
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Tariceanu",
                        votes     = 6
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Ponta",
                        votes     = 5
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Macovei",
                        votes     = 1
                    }
                }
            };

            SortingAndSearching.SortingAndSearching.Polls[] polls = new SortingAndSearching.SortingAndSearching.Polls[]
            {
                clujPoll,
                timisPoll,
                albaPoll
            };



            var expectedListOfCandidates = new SortingAndSearching.SortingAndSearching.Elections[]
            {
                new SortingAndSearching.SortingAndSearching.Elections()
                {
                    candidate = "Iohannis",
                    votes     = 32
                },

                new SortingAndSearching.SortingAndSearching.Elections()
                {
                    candidate = "Ponta",
                    votes     = 24
                },

                new SortingAndSearching.SortingAndSearching.Elections()
                {
                    candidate = "Tariceanu",
                    votes     = 16
                },

                new SortingAndSearching.SortingAndSearching.Elections()
                {
                    candidate = "Macovei",
                    votes     = 12
                }
            };

            SortingAndSearching.SortingAndSearching.Elections[] listOfCandidates = SortingAndSearching.SortingAndSearching.GetWinner(polls);

            for (int i = 0; i < expectedListOfCandidates.Length; i++)
            {
                Assert.AreEqual(expectedListOfCandidates[i].votes, listOfCandidates[i].votes);
                Assert.AreEqual(expectedListOfCandidates[i].candidate, listOfCandidates[i].candidate);
            }
        }
        public void Verify_Who_Won_THe_Elections()
        {
            var clujPoll = new SortingAndSearching.SortingAndSearching.Polls
            {
                elections = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Iohannis",
                   votes = 10
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate  = "Macovei",
                   votes = 9

                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Ponta",
                   votes = 8
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Tariceanu",
                   votes = 7
                    }
                }
            };

            var timisPoll = new SortingAndSearching.SortingAndSearching.Polls
            {
                elections = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                   candidate = "Ponta",
                   votes = 11
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Iohannis",
                   votes = 9
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Tariceanu",
                   votes = 3
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Macovei",
                   votes = 2
                    }
                }
            };

            var albaPoll = new SortingAndSearching.SortingAndSearching.Polls
            {
                elections = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Iohannis",
                   votes = 13
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Tariceanu",
                   votes = 6
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Ponta",
                   votes = 5
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {

                    candidate = "Macovei",
                   votes = 1
                    }
                }
            };

            SortingAndSearching.SortingAndSearching.Polls[] polls = new SortingAndSearching.SortingAndSearching.Polls[]
            {
                clujPoll,
                timisPoll,
                albaPoll
            };

            var expectedListOfCandidates = new SortingAndSearching.SortingAndSearching.Elections[]
                {
                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                          candidate = "Iohannis",
                         votes = 32
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                         candidate = "Ponta",
                         votes = 24
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                        candidate = "Tariceanu",
                        votes = 16
                    },

                    new SortingAndSearching.SortingAndSearching.Elections()
                    {
                         candidate = "Macovei",
                         votes = 12
                    }

            };

            SortingAndSearching.SortingAndSearching.Elections[] listOfCandidates = SortingAndSearching.SortingAndSearching.GetWinner(polls);

            for (int i = 0; i < expectedListOfCandidates.Length; i++)
            {
                Assert.AreEqual(expectedListOfCandidates[i].votes, listOfCandidates[i].votes);
                Assert.AreEqual(expectedListOfCandidates[i].candidate, listOfCandidates[i].candidate);
            }
        }