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); }
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); }
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 }); } }
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 }); } }