示例#1
0
        public void CloseRoueletteWinningByNumberAndColorTest()
        {
            var cache  = new MockCache();
            var random = new MockGenerateRandom();
            IRouletteService service = new RouletteService(cache, random);
            var dtoAdd   = service.AddRoulette();
            var dtoStart = service.StartRoulette(new Domain.Dtos.RouletteStartDto
            {
                Id = dtoAdd.Id
            });

            service.Bet("mna", new Domain.Dtos.RouletteBetDto
            {
                IdRoulette = dtoAdd.Id,
                CashAmount = 1000,
                Color      = Domain.Enums.ColorEnum.Red,
                Number     = 10
            });
            var dtoClose = service.CloseRoulette(new Domain.Dtos.RouletteCloseDto()
            {
                Id = dtoAdd.Id
            });

            Assert.IsTrue(dtoClose.WinningNumber == 10);
            Assert.IsTrue(dtoClose.Bets[0].WinnerAmount == 6800);
        }
示例#2
0
        public IEnumerable <Bets> CloseBetsxRoulette(Roulette roulette)
        {
            List <Bets> Bets = new List <Bets>();

            Bets = RouletteService.GetBets(roulette.Id);

            return(Bets);
        }
示例#3
0
        public IEnumerable <Roulette> GetRoulettes()
        {
            List <Roulette> Roulettes = new List <Roulette>();

            Roulettes = RouletteService.GetRoulettes();

            return(Roulettes);
        }
示例#4
0
        public void AddRouletteOkTest()
        {
            var cache  = new MockCache();
            var random = new MockGenerateRandom();
            IRouletteService service = new RouletteService(cache, random);
            var dto = service.AddRoulette();

            Assert.IsFalse(string.IsNullOrEmpty(dto.Id));
        }
示例#5
0
        public void StartRouletteFailTest()
        {
            var cache  = new MockCache();
            var random = new MockGenerateRandom();
            IRouletteService service = new RouletteService(cache, random);
            var dtoStart             = service.StartRoulette(new Domain.Dtos.RouletteStartDto()
            {
                Id = Guid.Empty.ToString()
            });

            Assert.IsTrue(dtoStart.Result == Domain.Enums.ResultEnum.Denied);
        }
示例#6
0
        public void StartRouletteSuccessTest()
        {
            var cache  = new MockCache();
            var random = new MockGenerateRandom();
            IRouletteService service = new RouletteService(cache, random);
            var dtoAdd   = service.AddRoulette();
            var dtoStart = service.StartRoulette(new Domain.Dtos.RouletteStartDto()
            {
                Id = dtoAdd.Id
            });

            Assert.IsTrue(dtoStart.Result == Domain.Enums.ResultEnum.Success);
        }
示例#7
0
        public void StartRouletteWithStatusCloseTest()
        {
            var cache  = new MockCache();
            var random = new MockGenerateRandom();
            IRouletteService service = new RouletteService(cache, random);
            var dtoAdd = service.AddRoulette();

            cache.roulettes.First(x => x.Id == dtoAdd.Id).Status = Domain.Enums.StatusEnum.Close;
            var dtoStart = service.StartRoulette(new Domain.Dtos.RouletteStartDto()
            {
                Id = dtoAdd.Id
            });

            Assert.IsTrue(dtoStart.Result == Domain.Enums.ResultEnum.Denied);
        }
示例#8
0
        public HttpResponseMessage OpenRoulette(Roulette roulette)
        {
            var response = Request.CreateResponse(HttpStatusCode.NotImplemented);

            var res = RouletteService.OpenRoulette(roulette.Id);

            if (res >= 1)
            {
                response = Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotModified);
            }


            return(response);
        }
示例#9
0
        public HttpResponseMessage CreateBet(HttpRequestMessage request, [FromBody] Bets bet)
        {
            var response = Request.CreateResponse(HttpStatusCode.NotImplemented);
            var headers  = request.Headers;
            var iduser   = headers.GetValues("User");

            bet.User_Id = Convert.ToInt32(iduser.FirstOrDefault());
            var res = RouletteService.CreateBet(bet);

            if (res >= 1)
            {
                response = Request.CreateResponse(HttpStatusCode.Created);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.BadRequest);
            }


            return(response);
        }
 public GetAllRouletteController(RouletteService rouletteService)
 {
     _rouletteService = rouletteService;
 }
 public RouletteController(RouletteService rouleteService)
 {
     _rouleteService = rouleteService;
 }
 public RouletteController(IDistributedCache distributedCache)
 {
     rouletteService = new RouletteService(distributedCache);
 }
示例#13
0
 public RouletteController(RouletteService rouletteService, BetService betService)
 {
     _rouletteService = rouletteService;
     _betService      = betService;
 }
示例#14
0
 public RouletteController(RouletteService rouletteService, BetsService betsService, IConfiguration configuration)
 {
     _betsService     = betsService;
     _rouletteService = rouletteService;
     Configuration    = configuration;
 }
 public RouletteController(IDatabase database)
 {
     _rouletteService = new RouletteService(database);
 }
示例#16
0
 public int CreateRoulette([FromBody] string value)
 {
     return(RouletteService.CreateRoulette());
 }