/// <summary> /// Initializes the server and game. /// </summary> /// <param name="startedCallback">The callback to invoke when initalization is completed.</param> public Task Initialize() { // Server setup IServerConfiguration serverConfig = new ServerConfiguration(); serverConfig.Port = 2000; var server = new StandardServer(new TestPlayerFactory(), new ConnectionFactory()); server.Configure(serverConfig); server.Owner = "@Scionwest"; this.Server = server; // Commanding setup var commandManager = new CommandManager(); commandManager.Configure(new CommandingConfiguration(new CommandFactory(new Type[] { typeof(LoginCommand), typeof(WalkCommand) }))); IGameConfiguration gameConfig = new GameConfiguration(); gameConfig.UseAdapter(server); gameConfig.UseAdapter(commandManager); IGame game = new MudGame(); game.Configure(gameConfig); this.Game = game; return(game.StartAsync()); }
public async Task Start_runs_the_game() { // Arrange var configuration = Mock.Of <IGameConfiguration>(); var game = new MudGame(); await game.Configure(configuration); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed // Act Task.Run(async() => await game.StartAsync()); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed await Task.Delay(TimeSpan.FromSeconds(2)); // Assert Assert.IsTrue(game.IsRunning); Assert.IsTrue(game.IsEnabled); }