public async Task <IActionResult> Retrieve()
        {
            var query   = new RetrieveBetsQuery();
            var betsDto = await _module.ExecuteQueryAsync(query);

            return(Ok(betsDto));
        }
예제 #2
0
        public async Task HandleShouldReturnBetsMemberCreated()
        {
            //arrange
            var memberId = Guid.NewGuid();
            var query    = new RetrieveBetsQuery();
            var bets     = new List <BetDto>
            {
                new BetDto(new BetState(Guid.NewGuid(),
                                        new(new(memberId), "toto", 300),
                                        new DateTime(2021, 4, 3), "desc1",
                                        30, new DateTime(2021, 2, 2),
                                        new List <AnswerState>(), null, null)),
                new BetDto(new BetState(Guid.NewGuid(),
                                        new(new(memberId), "toto", 300),
                                        new DateTime(2021, 6, 3), "desc2",
                                        30, new DateTime(2021, 3, 2),
                                        new List <AnswerState>(), null, null))
            };
            IBetQueryRepository betRepository = new InMemoryBetQueryRepository(new(bets));
            var handler = new RetrieveBetsQueryHandler(betRepository);

            //act
            var betsResult = await handler.Handle(query, default);

            //assert
            Assert.Equal(2, betsResult.Count);
        }
예제 #3
0
        public async Task HandleShouldReturn0BetsIfMemberHasNeverParticipateToBet()
        {
            //arrange
            var query   = new RetrieveBetsQuery();
            var handler = new RetrieveBetsQueryHandler(new InMemoryBetQueryRepository(new List <BetDto>()));

            //act
            var result = await handler.Handle(query, default);

            //assert
            Assert.Empty(result);
        }
예제 #4
0
 public async Task ShouldReturnBetsMemberHasParticipated()
 {
     //arrange
     var memberId = Guid.NewGuid();
     var query    = new RetrieveBetsQuery();
     var bets     = new List <BetDto>
     {
         new BetDto(new BetState(Guid.NewGuid(),
                                 new(new(memberId), "toto", 300),
                                 new DateTime(2021, 4, 3), "desc1",
                                 30, new DateTime(2021, 2, 2),
                                 new List <AnswerState>()
         {
             new AnswerState(new(new(memberId), "name", 300), true, new DateTime(2021, 3, 5))
         }, null, null))