コード例 #1
0
        public void AddVoterWithDelegateTest()
        {
            IVoterController voterController = new VoterController();

            voterController.AddVoterWithDelegate("Alice", "Bob");

            IDictionary <String, int> choices = voterController.GetAggregatedVoterChoicesForValidVotes()
                                                .ToDictionary(pair => pair.Key, pair => pair.Value);

            Assert.Equal(0, choices.Count);
        }
コード例 #2
0
        public void AddVoterWithChoiceAndDelegateTest()
        {
            IVoterController voterController = new VoterController();

            voterController.AddVoterWithChoice("Alice", "Pizza");
            voterController.AddVoterWithDelegate("Alice", "Bob");
            IDictionary <String, int> choices = voterController.GetAggregatedVoterChoicesForValidVotes()
                                                .ToDictionary(pair => pair.Key, pair => pair.Value);

            Assert.True(choices.ContainsKey("Pizza"));
            Assert.Equal(2, choices["Pizza"]);
        }
コード例 #3
0
        public void GetAggregatedVoterChoicesForInValidVotesTest()
        {
            IVoterController voterController = new VoterController();

            voterController.AddVoterWithChoice("Alice", "Pizza");
            voterController.AddVoterWithDelegate("Bob", "Carol");
            voterController.AddVoterWithChoice("Carol", "Salad");
            voterController.AddVoterWithDelegate("Dave", "Eve");
            voterController.AddVoterWithDelegate("Eve", "Mallory");
            voterController.AddVoterWithChoice("Eve", "Pizza");
            voterController.AddVoterWithDelegate("Mallory", "Eve");

            IDictionary <String, int> invalidVotes = voterController.GetAggregatedVoterChoicesForInValidVotes()
                                                     .ToDictionary(pair => pair.Key, pair => pair.Value);

            Assert.True(invalidVotes.ContainsKey("invalid"));
            Assert.Equal(3, invalidVotes["invalid"]);
        }