public void TestThat_VotesForIPAddress_ThrowsAnException_WhenTheSuppliedIPAddressIsInavlid(string ipAddress)
 {
     var controller = new VotingControllerBuilder().Build();
     Assert.Throws<ArgumentException>(() => controller.VotesForIPAddress(ipAddress));
 }
        public void TestThat_VotesForIPAddress_SetsTheIPAddressOnTheModel()
        {
            var votes = new[] {new CookieVoteModel(), new CookieVoteModel()};
            var dataProvider = new DataProviderBuilder().WithVotesForIPAddresses(votes).Build();
            var controller = new VotingControllerBuilder().WithDataProvider(dataProvider).Build();

            var model = controller.VotesForIPAddress("1.2.3.4").GetViewModel<VotesForIpAddressViewModel>();

            Assert.That(model.IPAddress, Is.EqualTo("1.2.3.4"));
        }
        public void TestThat_VotesForIPAddress_SetsTheVotesObtainedFromTheDataProviderOnTheModel()
        {
            var votes = new[] {new CookieVoteModel(), new CookieVoteModel()};
            var dataProvider = new DataProviderBuilder().WithVotesForIPAddresses(votes).Build();
            var controller = new VotingControllerBuilder().WithDataProvider(dataProvider).Build();

            var model = controller.VotesForIPAddress("1.2.3.4").GetViewModel<VotesForIpAddressViewModel>();

            CollectionAssert.AreEquivalent(votes, model.DistinctVotes);
        }
        public void TestThat_VotesForIPAddress_SetsTheHighestOccuringNumberOfVotesOnTheModel()
        {
            var votes = new[] {new CookieVoteModel {NumberOfVotes = 2}, new CookieVoteModel {NumberOfVotes = 4}};
            var dataProvider = new DataProviderBuilder().WithVotesForIPAddresses(votes).Build();
            var controller = new VotingControllerBuilder().WithDataProvider(dataProvider).Build();

            var model = controller.VotesForIPAddress("1.2.3.4").GetViewModel<VotesForIpAddressViewModel>();

            Assert.That(model.HighestNumberOfVotes, Is.EqualTo(4));
        }