Пример #1
0
        public GameStateProviderTests()
        {
            _dummyPlayer = GetDummyPlayer();
            _dummyMap = GetDummyMap();

            _gameStateRepository = Substitute.For<IGameStateRepository>();
            _playersProvider = Substitute.For<IPlayersProvider>();
            _playersProvider.Get(Guid.Empty).ReturnsForAnyArgs(_dummyPlayer);
            _mapProvider = Substitute.For<IMapProvider>();
            _mapProvider.GetRandomMap().ReturnsForAnyArgs(_dummyMap);
            _gameStateProvider = new GameStateProvider(_gameStateRepository, _playersProvider, _mapProvider);
        }
Пример #2
0
        public GameStateProviderTests()
        {
            _dummyPlayer = GetDummyPlayer();
            _dummyMap    = GetDummyMap();

            _gameStateRepository = Substitute.For <IGameStateRepository>();
            _playersProvider     = Substitute.For <IPlayersProvider>();
            _playersProvider.Get(Guid.Empty).ReturnsForAnyArgs(_dummyPlayer);
            _mapProvider = Substitute.For <IMapProvider>();
            _mapProvider.GetRandomMap().ReturnsForAnyArgs(_dummyMap);
            _gameStateProvider = new GameStateProvider(_gameStateRepository, _playersProvider, _mapProvider);
        }
Пример #3
0
 public InMemoryGameStateRepository(IMapProvider maps)
 {
     if (State.Count == 0)
     {
         Guid id = Guid.NewGuid();
         State.Add(id, new GameState {
             Id = id, Turn = 0, Name = "Game 1", MapId = maps.GetRandomMap().Id
         });
         id = Guid.NewGuid();
         State.Add(id, new GameState {
             Id = id, Turn = 0, Name = "Game 2", MapId = maps.GetRandomMap().Id
         });
         id = Guid.NewGuid();
         State.Add(id, new GameState {
             Id = id, Turn = 0, Name = "Game 3", MapId = maps.GetRandomMap().Id
         });
         id = Guid.NewGuid();
         State.Add(id, new GameState {
             Id = id, Turn = 0, Name = "Game 4", MapId = maps.GetRandomMap().Id
         });
         id = Guid.NewGuid();
         State.Add(id, new GameState {
             Id = id, Turn = 0, Name = "Game 5", MapId = maps.GetRandomMap().Id
         });
         id = Guid.NewGuid();
         State.Add(id, new GameState {
             Id = id, Turn = 0, Name = "Game 6", MapId = maps.GetRandomMap().Id
         });
     }
 }
Пример #4
0
        public ValidationResult <GameState> CreateGame(string name)
        {
            if (_repo.GetByName(name) != null)
            {
                return(ValidationResult <GameState> .Failure("A game by that name already exists"));
            }

            var id = Guid.NewGuid();

            var gameState = new GameState {
                Id = id, Name = name, MapId = _mapProvider.GetRandomMap().Id, Started = false
            };

            _repo.Add(gameState);
            _repo.Save();

            return(ValidationResult <GameState> .Success.WithData(gameState));
        }
 public InMemoryGameStateRepository(IMapProvider maps)
 {
     if (State.Count == 0)
     {
         Guid id = Guid.NewGuid();
         State.Add(id, new GameState { Id = id, Turn = 0, Name = "Game 1", MapId = maps.GetRandomMap().Id });
         id = Guid.NewGuid();
         State.Add(id, new GameState { Id = id, Turn = 0, Name = "Game 2", MapId = maps.GetRandomMap().Id });
         id = Guid.NewGuid();
         State.Add(id, new GameState { Id = id, Turn = 0, Name = "Game 3", MapId = maps.GetRandomMap().Id });
         id = Guid.NewGuid();
         State.Add(id, new GameState { Id = id, Turn = 0, Name = "Game 4", MapId = maps.GetRandomMap().Id });
         id = Guid.NewGuid();
         State.Add(id, new GameState { Id = id, Turn = 0, Name = "Game 5", MapId = maps.GetRandomMap().Id });
         id = Guid.NewGuid();
         State.Add(id, new GameState { Id = id, Turn = 0, Name = "Game 6", MapId = maps.GetRandomMap().Id });
     }
 }