37 lines
942 B
C#
37 lines
942 B
C#
using NUnit.Framework;
|
|
|
|
namespace VideoGameQuotes.Api.Tests {
|
|
[TestFixture]
|
|
public class QuoteTests {
|
|
|
|
[Test]
|
|
[ExpectedException(typeof(CannotVoteTwiceException))]
|
|
public void Should_not_allow_voting_in_the_same_direction_twice() {
|
|
var quote = new Quote();
|
|
var user = new User();
|
|
|
|
quote.VoteFor(user, VoteDirection.Up);
|
|
quote.VoteFor(user, VoteDirection.Up);
|
|
}
|
|
|
|
[Test]
|
|
public void Should_remove_old_vote_if_voting_in_opposite_direction() {
|
|
var quote = new Quote();
|
|
var user = new User();
|
|
|
|
quote.VoteFor(user, VoteDirection.Up);
|
|
|
|
Assert.That(quote.UpVotes, Is.EqualTo(1));
|
|
Assert.That(quote.DownVotes, Is.EqualTo(0));
|
|
Assert.That(quote.NetVotes, Is.EqualTo(1));
|
|
|
|
quote.VoteFor(user, VoteDirection.Down);
|
|
|
|
Assert.That(quote.UpVotes, Is.EqualTo(0));
|
|
Assert.That(quote.DownVotes, Is.EqualTo(1));
|
|
Assert.That(quote.NetVotes, Is.EqualTo(-1));
|
|
}
|
|
|
|
}
|
|
}
|