Esempio n. 1
0
        public async Task Prepare()
        {
            //TODO: remove this later on
            var sampleUser = new User {
                FirstName = "John", LastName = "Doe", Email = "*****@*****.**", PasswordHash = "AQAAAAEAACcQAAAAEEI1y09DRnWeVEUmJfBSYoLkYp6Ps+yQZTdxGB3PKWzX/GNs/P8BxIyqGOc/VGIEDA==", IsEmailConfirmed = true
            };
            var user = await FindUserAsync(sampleUser.Email);

            if (user == null)
            {
                user = await RegisterUserAsync(sampleUser);
            }

            var keysUser = Builders <User> .IndexKeys.Ascending("Email");

            CreateIndexModel <User> userIndex = new CreateIndexModel <User>(keysUser);
            await Users.Indexes.CreateOneAsync(userIndex);

            var keysGame = Builders <GameState> .IndexKeys.Ascending("GameId");

            CreateIndexModel <GameState> gameIndex = new CreateIndexModel <GameState>(keysGame);
            await Games.Indexes.CreateOneAsync(gameIndex);

            var statistics = await GetClientStatisticsAsync();

            if (statistics == null)
            {
                await Statistics.InsertOneAsync(ClientStatistics.CreateNew());
            }
        }
        public Task Prepare()
        {
            var user = new User {
                FirstName = "John", LastName = "Doe", Email = "*****@*****.**", PasswordHash = "AQAAAAEAACcQAAAAEEI1y09DRnWeVEUmJfBSYoLkYp6Ps+yQZTdxGB3PKWzX/GNs/P8BxIyqGOc/VGIEDA==", IsEmailConfirmed = true
            };

            _users.AddOrUpdate(user.Email, user, (key, val) => user);

            ClientStatistics stat = ClientStatistics.CreateNew();

            _clientStatistics.GetOrAdd(typeof(ClientStatistics).ToString(), stat);

            return(Task.FromResult(0));
        }