Exemplo n.º 1
0
        public void Given_Topics_When_CreateVoting_Then_VotingCreated()
        {
            // Arrange
            var sut    = new VotingAggregate();
            var topics = new[] { "C#", "F#", "Java", "JS" };

            // Act
            sut.CreateVoting(topics);

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

            Assert.NotNull(result);
            Assert.Equal(result.Topics, topics);
        }
Exemplo n.º 2
0
        public void Given_CreatedVoting_WithOneTopic_When_StartVoting_Then_VotingFinished()
        {
            // Arrange
            var sut = new VotingAggregate();

            sut.CreateVoting("C#");

            // Act
            sut.StartNextVoting();

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

            Assert.NotNull(result);
            Assert.Equal(result.Winner, "C#");
        }
Exemplo n.º 3
0
        public void Given_CreatedVoting_When_StartNextVoting_Then_VotingStarted()
        {
            // Arrange
            var sut = new VotingAggregate();

            sut.CreateVoting("C#", "F#", "VB.NET", "PowerShell");

            // Act
            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));
            Assert.Equal(result.RemainingTopics, new[] { "VB.NET", "PowerShell" });
        }
Exemplo n.º 4
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));
        }