Beispiel #1
0
        public void Given_StartedVoting_When_VoteManyTimes_Then_VotingStarted()
        {
            // Arrange
            var sut = new VotingAggregate();

            sut.CreateVoting("C#", "F#");
            sut.StartNextVoting();

            // Act
            sut.VoteTopic("C#");
            sut.VoteTopic("F#");
            sut.StartNextVoting();

            // Assert
            var result = sut.GetPendingEvents().OfType <VotingStartedEvent>().First();

            Assert.NotNull(result);
            Assert.Equal(result.VotingPair.TopicA, ("C#", 0));
            Assert.Equal(result.VotingPair.TopicB, ("F#", 0));
        }
Beispiel #2
0
        public void Given_StartedVoting_When_VoteForNonExistingTopic_Then_Exception()
        {
            // Arrange
            var sut = new VotingAggregate();

            sut.CreateVoting("C#", "F#");
            sut.StartNextVoting();

            // Act
            Action result = () => sut.VoteTopic("Haskell");

            // Assert
            Assert.ThrowsAny <InvalidOperationException>(result);
        }
Beispiel #3
0
        public void Given_StartedVoting_CreatedWithTwoTopics_When_VoteTopic_Then_VotingFinished()
        {
            // Arrange
            var sut = new VotingAggregate();

            sut.CreateVoting("C#", "F#");
            sut.StartNextVoting();

            // Act
            sut.VoteTopic("C#");
            sut.StartNextVoting();

            // Assert
            var result = sut.GetPendingEvents().OfType <VotingFinishedEvent>().First();

            Assert.NotNull(result);
            Assert.Equal(result.Winner, "C#");
        }