protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainMenuView); System.Threading.ThreadPool.SetMinThreads(30, 30); //Arrange var authenticationOptions = new AuthenticationOptions() { BaseUri = new Uri("http://www.glueware.nl/klootzakken/kz/") }; var authenticationService = new AuthenticationService(authenticationOptions); var apiClientOptions = new ApiClientOptions() { BaseUri = new Uri("http://www.glueware.nl/klootzakken/kzapi/") }; var apiClient = new DefaultApiClient(authenticationService, apiClientOptions); var lobbyStatusService = new LobbyStatusService(apiClient); var lobbyActionService = new LobbyActionService(apiClient); //Act string randomString = Guid.NewGuid().ToString("n").Substring(0, 8); var isCreateGameSucces = await lobbyActionService.CreateLobbyAsync(randomString); var lobbies = await lobbyStatusService.GetLobbiesAsync(); var createdLobby = lobbies.Find(l => l.Name.Equals(randomString)); var joinedToLobby = await lobbyActionService.JoinLobbyAsync(createdLobby.Id); var myLobbyies = await lobbyStatusService.GetMyLobbiesAsync(); var justJoinedMyLobby = myLobbyies.Find(l => l.Name.Equals(randomString)); var gameIsStarted = await lobbyActionService.StartGameForLobbyAsync(createdLobby.Id); //Assert myGames = new List <string> { "GetLobbiesAsync() - " + randomString.Equals(createdLobby.Name).ToString(), "GetMyLobbiesAsync() - " + randomString.Equals(justJoinedMyLobby.Name).ToString(), "CreateLobbyAsync() - " + isCreateGameSucces.ToString(), "JoinLobbyAsync() - " + joinedToLobby.ToString(), "StartGameForLobbyAsync() - " + gameIsStarted.ToString() }; myGamesListView = FindViewById <ListView>(Resource.Id.myGamesListView); myGamesListView.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myGames); Button createGame = FindViewById <Button>(Resource.Id.btnCreateGame); createGame.Click += delegate { StartActivity(typeof(MainActivity)); }; }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainMenuView); var authenticationOptions = new AuthenticationOptions() { BaseUri = new Uri("http://10.0.2.2:5000/") }; var authenticationService = new AuthenticationService(authenticationOptions); var apiClientOptions = new ApiClientOptions() { BaseUri = new Uri("http://10.0.2.2:5000/") }; var apiClient = new DefaultApiClient(authenticationService, apiClientOptions); var lobbyStatusService = new LobbyStatusService(apiClient); var lobbyActionService = new LobbyActionService(apiClient); bool isCreatingLobbySucces = false; List <LobbyView> lobbyViews = null; try { isCreatingLobbySucces = await lobbyActionService.CreateLobbyAsync("dani2Lobby"); lobbyViews = await lobbyStatusService.GetLobbiesAsync(); } catch (Exception e) { Console.Write(e); } myGamesListView = FindViewById <ListView>(Resource.Id.myGamesListView); myGames = new List <string> { isCreatingLobbySucces.ToString() }; myGamesListView.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myGames); Button createGame = FindViewById <Button>(Resource.Id.btnCreateGame); createGame.Click += delegate { StartActivity(typeof(MainActivity)); //TODO: make a new activity for creating new game }; }
public void mockedApiClient_getLobbies_returnsLobbies() { //ARRANGE var expectedLobbies = new List <LobbyView> { lobbyView_1, lobbyView_2, lobbyView_3 }; var mockedApiClient = new Mock <IApiClient>(); mockedApiClient.Setup(client => client.GetAsync <List <LobbyView> >(It.IsAny <string>())).ReturnsAsync(expectedLobbies); var sut = new LobbyStatusService(mockedApiClient.Object); //ACT var lobbies = sut.GetLobbiesAsync().Result; //ASSERT lobbies.Should().BeAssignableTo <List <LobbyView> >(); Assert.Equal(lobbies, expectedLobbies); //TODO: tests for throwing exception }