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"]); }
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); }
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"]); }