Esempio n. 1
0
        public void Given_StartedVoting_When_Finish_With_Same_Votes_Then_Exception()
        {
            var voting = new Voting();

            voting.Start("DEV", "OPS");
            voting.Vote("DEV");
            voting.Vote("OPS");

            Action action = () => voting.Finish();

            Assert.ThrowsAny <InvalidOperationException>(action);
        }
Esempio n. 2
0
        public void Given_StartedVoting_When_Finish_Then_Winner()
        {
            var voting = new Voting();

            voting.Start("DEV", "OPS");
            voting.Vote("DEV");
            voting.Vote("DEV");
            voting.Vote("OPS");

            voting.Finish();

            Assert.Equal("DEV", voting.Winner);
        }
Esempio n. 3
0
        public void Given_NotStartedVoting_When_Vote_Then_Exception()
        {
            var voting = new Voting();

            Action action = () => voting.Vote("C#");

            Assert.ThrowsAny <InvalidOperationException>(action);
        }
Esempio n. 4
0
        public void Finish_Testing()
        {
            var voting = new Voting();

            voting.Start("C#", "Java");
            voting.Vote("C#");
            var votingState = voting.Finish();

            Assert.Equal("C#", votingState.Winner);
        }
Esempio n. 5
0
        public void Given_StartedVoting_When_Vote_ForNotValid_Topic_Then_Exception()
        {
            var voting = new Voting();

            voting.Start("DEV", "OPS");

            Action action = () => voting.Vote("DEVOPS");

            Assert.ThrowsAny <InvalidOperationException>(action);
        }
Esempio n. 6
0
        public void Vote_Test()
        {
            var voting = new Voting();

            voting.Start("C#", "Java");
            voting.Vote("C#");

            Assert.Equal(new Dictionary <string, int> {
                { "C#", 1 },
                { "Java", 0 },
            }, voting.Votes);
        }
Esempio n. 7
0
        public void Given_StartedVoting_When_Vote_Then_VoteCreated()
        {
            var voting = new Voting();

            voting.Start("DEV", "OPS");

            voting.Vote("DEV");
            Assert.Equal(voting.Votes, new Dictionary <string, int>()
            {
                { "DEV", 1 },
                { "OPS", 0 }
            });
        }
Esempio n. 8
0
 public async Task <object> Vote([FromBody] string topic) =>
 await ExecuteCommand(() => _voting.Vote(topic));
Esempio n. 9
0
 public object Put([FromBody] string value)
 {
     _voting.Vote(value);
     return(_voting.GetState());
 }