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));
            };
        }
Exemple #2
0
        public void mockedApiClient_getMyLobbies_returnsMyLobbies()
        {
            //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.GetMyLobbiesAsync().Result;

            //ASSERT
            lobbies.Should().BeAssignableTo <List <LobbyView> >();
            Assert.Equal(lobbies, expectedLobbies);
        }