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"]); }
public void GetAggregatedVoterChoicesForValidVotesTest() { 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> choices = voterController.GetAggregatedVoterChoicesForValidVotes() .ToDictionary(pair => pair.Key, pair => pair.Value); Assert.True(choices.ContainsKey("Pizza")); Assert.Equal(1, choices["Pizza"]); Assert.True(choices.ContainsKey("Salad")); Assert.Equal(2, choices["Salad"]); }