public async Task Setup()
        {
            if (initialized)
            {
                return;
            }

            // create db context
            _dbContext = Helpers.GetNewDbContext("CasinoDbRoulettesComponentsTest");

            _identity = new IdentityAppMock();

            _component = new RoulettesCrudComponent(_identity, _mapper, _pagedRecords);
            _component.AppDbContext = _dbContext;

            // add roulettes db dependencies
            RouletteState rouletteActiveState = new RouletteState {
                State = "Active"
            };

            _dbContext.RouletteStates.Add(rouletteActiveState);
            RouletteState rouletteInactiveState = new RouletteState {
                State = "Inactive"
            };

            _dbContext.RouletteStates.Add(rouletteInactiveState);

            RouletteType rouletteEuropeanType = new RouletteType {
                Type = "European"
            };

            _dbContext.RouletteTypes.Add(rouletteEuropeanType);
            RouletteType rouletteAmercianType = new RouletteType {
                Type = "American"
            };

            _dbContext.RouletteTypes.Add(rouletteAmercianType);

            // add 4 rouletttes to db
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette A", State = rouletteActiveState, Type = rouletteEuropeanType
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette B", State = rouletteActiveState, Type = rouletteEuropeanType
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette C", State = rouletteActiveState, Type = rouletteAmercianType
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette D", State = rouletteActiveState, Type = rouletteAmercianType
            });

            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette E", State = rouletteInactiveState, Type = rouletteEuropeanType
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette F", State = rouletteInactiveState, Type = rouletteEuropeanType
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette G", State = rouletteInactiveState, Type = rouletteAmercianType
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette G", State = rouletteInactiveState, Type = rouletteAmercianType
            });

            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette YYY", State = rouletteActiveState, Type = rouletteEuropeanType, DeletedAt = DateTime.Now
            });
            _dbContext.Roulettes.Add(new Roulette {
                Description = "roulette ZZZ", State = rouletteActiveState, Type = rouletteEuropeanType, DeletedAt = DateTime.Now
            });

            await _dbContext.SaveChangesAsync();

            initialized = true;
        }
示例#2
0
文件: Wheel.cs 项目: jthapa01/CSharp
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public Wheel(RouletteType rouletteType, ILuckTeller luckTell)
 {
     _luckTeller = luckTell;
     _bins       = InitializeBins((byte)((rouletteType == RouletteType.American)? 38: 37));
 }