public async Task Given_CreatedVoting_When_StartAndVoteAndFinish_Then_SameSnapshots()
        {
            var sut = new VotingReadModelService(new FakeRepo());
            await sut.AddOrUpdate(GetCreatedEvent());

            var snapshot = await sut.AddOrUpdate(new VotingStartedEvent(votingId, new string[] { }, VotingPair.Create("C#", "F#")));

            var result = await sut.Get(votingId);

            Assert.Equal(result.Topics, snapshot.Topics);

            snapshot = await sut.AddOrUpdate(new TopicVotedEvent(votingId, "C#"));

            result = await sut.Get(votingId);

            Assert.Equal(result.Topics, snapshot.Topics);

            snapshot = await sut.AddOrUpdate(new VotingFinishedEvent(votingId, "C#"));

            result = await sut.Get(votingId);

            Assert.Equal(result.Topics, snapshot.Topics);
            Assert.Equal(result.Winner, snapshot.Winner);
        }
Esempio n. 2
0
 public async Task <VotingSnapshot> GetVoting(Guid id) => await _readModelService.Get(id);