public async Task ExecuteGetAllMembers()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Members.Clear();
                foreach (string member_uid in Team.member)
                {
                    User member = await UsersFirestore.GetUserByUIDAsync(member_uid);

                    Members.Add(member);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task Test4_GetUsersByID()
        {
            //Arrange
            string UID = "ryZJ4v8INRes4o2ZxEaNOPDtqgo2";

            //Act
            var user = await UsersFirestore.GetUserByUIDAsync(UID);

            //Assert
            Assert.True(user.email.Equals("*****@*****.**"));
        }
        public async Task Test3_GetUsersByID()
        {
            //Arrange
            string UID = "HcHGkaJGpoOSNZ19hzqUjPqcoHj1";

            //Act
            var user = await UsersFirestore.GetUserByUIDAsync(UID);

            //Assert
            Assert.True(user.phone.Equals("0452312423"));
        }
        public async Task Test2_GetUsersByID()
        {
            //Arrange
            string UID = "6H7I6z5BsDcyU1xP53DG2CAHOj53";

            //Act
            var user = await UsersFirestore.GetUserByUIDAsync(UID);

            //Assert
            Assert.True(user.name.Equals("Fiora"));
        }
        public async Task Test5_GetUsersAvatar()
        {
            //Arrange
            string UID  = "ryZJ4v8INRes4o2ZxEaNOPDtqgo2";
            var    user = await UsersFirestore.GetUserByUIDAsync(UID);

            //Act
            var avatar = await UsersFirestore.GetUserAvatarURLAsync(user);

            //Assert
            Assert.True(user.email.Equals("https://firebasestorage.googleapis.com/v0/b/teamup-b7a43.appspot.com/o/images%2Fuser%2FVolibear%2Fdownload.jpg?alt=media&token=2f3f1b00-e28c-4e08-81c2-b48ba072d185"));
        }
Exemplo n.º 6
0
        /**
         * The Function when the WebView is navigated (is on)
         */
        private async void WebViewOnNavigated(object sender, WebNavigatedEventArgs e)
        {
            /* Get the AccessToken from Facebook Server. Using the function written below
             *
             *  private string ExtractAccessTokenFromUrl(string url)
             */
            var accessToken = ExtractAccessTokenFromUrl(e.Url);

            // If successfully have the AccessToken
            if (accessToken != "")
            {
                // Then we send them to the FacebookLogInPage with its ViewModel
                var vm = BindingContext as FacebookLogInPageViewModel;

                // Set their Profile using the Function written in its ViewModel with the AccessToken
                await vm.SetFacebookUserProfileAsync(accessToken);

                // Set the userUID to the app

                Content = MainStackLayout;

                vm.IsBusy = true;

                // Authenticate user with Firebase Authentication & send the UID to the Firebase Server
                string FirebaseUserUID = await AuthenticationFirebase.AuthenticateFacebookAsync(accessToken);

                // Check if User is new ??
                bool isNew = await UsersFirestore.IsNewUser(FirebaseUserUID);

                if (!isNew)
                {
                    UsersFirestore.myProfile = await UsersFirestore.GetUserByUIDAsync(FirebaseUserUID);

                    vm.IsBusy = false;

                    // Welcome back Page
                    WelcomeView.IsVisible = true;
                }
                else
                {
                    // Init a new user details based on Facebook Profile
                    vm.FirstUserInit(FirebaseUserUID);
                    vm.IsBusy = false;

                    // User question add page
                    RegisterView.IsVisible = true;
                }
            }
        }
        public async Task Test7_RemoveNotificationFromUser()
        {
            //Arrange
            string user_id         = "mTwtRUKrzfamBp6PUEMGPMCRNBy1";
            string notification_id = "6xyKcZwxg1cXjUkjaggIf8WGWzu11fhFeGGSZsIyQqwPkuMA";

            //Act
            //Remove the specific notification from the user document
            await UsersFirestore.RemoveNotificationFromUserAsync(user_id, notification_id);

            //Fetch again the new document
            var user = await UsersFirestore.GetUserByUIDAsync(user_id);

            //Assert
            Assert.DoesNotContain(notification_id, user.notification_id);
        }
        public async Task Test2_LoadTeamsCommand()
        {
            //Arrange
            //Init the user
            string uid  = "HcHGkaJGpoOSNZ19hzqUjPqcoHj1";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            var vm = new MyTeamsPageViewModel();

            //Act
            vm.LoadTeamsCommand.Execute(null);

            //Assert
            Assert.True(vm.teamsList.Count > 1);
        }
        public async Task Test1_LoadTeamsCommand()
        {
            //Arrange
            //Init the user
            string uid  = "6H7I6z5BsDcyU1xP53DG2CAHOj53";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            var vm = new MyTeamsPageViewModel();

            //Act
            vm.LoadTeamsCommand.Execute(null);

            //Assert
            Assert.True(vm.teamsList.Count > 1);
        }
        public async Task Test3_LoadTeamsCommand()
        {
            //Arrange
            //Init the user
            string uid  = "6xyKcZwxg1cXjUkjaggIf8WGWzu1";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            var vm = new MyTeamsPageViewModel();

            //Act
            vm.LoadTeamsCommand.Execute(null);

            //Assert
            Assert.True(vm.teamsList[0].Id.Equals("1fhFeGGSZsIyQqwPkuMA"));
        }
Exemplo n.º 11
0
        public async Task Test2_LoadMyProfile()
        {
            //Arrange
            //Init the user
            string uid  = "ryZJ4v8INRes4o2ZxEaNOPDtqgo2";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            var vm = new ProfilePageViewModel();

            //Act
            vm.LoadMyProfile.Execute(null);

            //Assert
            Assert.True(vm.User.name.Equals("Volibear"));
        }
Exemplo n.º 12
0
        public async Task Test3_LoadMyProfile()
        {
            //Arrange
            //Init the user
            string uid  = "mTwtRUKrzfamBp6PUEMGPMCRNBy1";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            var vm = new ProfilePageViewModel();

            //Act
            vm.LoadMyProfile.Execute(null);

            //Assert
            Assert.Contains("1fhFeGGSZsIyQqwPkuMA", vm.User.team_leader);
        }
Exemplo n.º 13
0
        public async Task Test1_LoadMyProfile()
        {
            //Arrange
            //Init the user
            string uid  = "6H7I6z5BsDcyU1xP53DG2CAHOj53";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            var vm = new ProfilePageViewModel();

            //Act
            vm.LoadMyProfile.Execute(null);

            //Assert
            Assert.True(vm.User.name.Equals("Fiora"));
        }
        public async Task Test6_RemoveTeamFromUser()
        {
            //Arrange
            string team_id = "1fhFeGGSZsIyQqwPkuMA";
            var    team    = await TeamsFirestore.GetTeamByIdAsync(team_id);

            string user_id = "6H7I6z5BsDcyU1xP53DG2CAHOj53";

            //Act
            //Remove the specific team from the user document
            await UsersFirestore.RemoveTeamFromUserAsync(user_id, team);

            //Fetch again the new document
            var user = await UsersFirestore.GetUserByUIDAsync(user_id);

            //Assert
            Assert.DoesNotContain(team_id, user.team_uid);
        }
Exemplo n.º 15
0
        public async Task Test3_LoadMyProfile()
        {
            //Arrange
            string uid  = "6H7I6z5BsDcyU1xP53DG2CAHOj53";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            string team_id = "sYvjfjfqarGNAptZ5myb";
            var    team    = await TeamsFirestore.GetTeamByIdAsync(team_id);

            var vm = new TeamDetailsPageViewModel(team);

            //Act


            //Assert
            Assert.True(vm.TeamLeader.Equals("HcHGkaJGpoOSNZ19hzqUjPqcoHj1"));
        }
Exemplo n.º 16
0
        public async Task Test2_LoadMyProfile()
        {
            //Arrange
            string uid  = "6H7I6z5BsDcyU1xP53DG2CAHOj53";
            var    user = await UsersFirestore.GetUserByUIDAsync(uid);

            UsersFirestore.myProfile = user;

            string team_id = "Xu3FwHcyJpeDuXIk1vti";
            var    team    = await TeamsFirestore.GetTeamByIdAsync(team_id);

            var vm = new TeamDetailsPageViewModel(team);

            //Act


            //Assert
            Assert.True(vm.isTeamLeader);
        }
Exemplo n.º 17
0
        async Task ExecuteLoadNotificationsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                notificationsList.Clear();
                var notifications = await NotificationsFirestore.GetMyNotificationsAsync();

                foreach (var notification in notifications)
                {
                    // Set the visibility of each notification
                    setVisibility(notification);

                    if (notification.isVisible)
                    {
                        // Load team & user
                        notification.team = await TeamsFirestore.GetTeamByIdAsync(notification.team_id);

                        notification.user = await UsersFirestore.GetUserByUIDAsync(notification.user_id);

                        // Create a message
                        setNotificationContent(notification);

                        notificationsList.Add(notification);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public TeamDetailsPageViewModel(Team team = null)
        {
            Title = team?.name;
            Team  = team;

            //Load leaders
            new Command(async() => { TeamLeader = await UsersFirestore.GetUserByUIDAsync(Team.team_leader); }).Execute(null);

            //Load members
            Members = new ObservableCollection <User>();
            new Command(async() => await ExecuteGetAllMembers()).Execute(null);

            // Whether this user is the team leader
            if (UsersFirestore.myProfile.team_leader.Contains(team.Id))
            {
                isTeamLeader = true;
            }
            else
            {
                isTeamLeader = false;
            }
        }