Ejemplo n.º 1
0
        public void UserReviewGetterTest()
        {
            LocalUser user   = UnitTestAuth.Login();
            var       status = UserReviewsGetStatus.UnknownError;
            bool      done   = false;

            List <UserReview>         userReviews = null;
            Dictionary <String, User> users       = null;


            var getter = UserReviewSystemManager.NewUserReviewGetter();

            getter.Result += (_status, _userReviews, _users) => {
                status      = _status;
                userReviews = _userReviews;
                users       = _users;
                done        = true;
            };

            getter.Get(user.Username, true);
            while (!done)
            {
            }
            Assert.AreEqual(status, UserReviewsGetStatus.Success);
            Assert.AreNotEqual(users, null);
            Assert.AreNotEqual(userReviews, null);
        }
Ejemplo n.º 2
0
        private void GetUserReviews()
        {
            var userReviewGetter = UserReviewSystemManager.NewUserReviewGetter();

            userReviewGetter.Result += (status, userReviews, users) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (status == UserReviewsGetStatus.Success)
                    {
                        buttonDelete.IsEnabled = false;
                        buttonDelete.Text      = "";
                        Items.Clear();
                        userReviews.ForEach(UserReview =>
                        {
                            if (UserReview.Username == LocalUserManager.LocalUser.Username)
                            {
                                buttonDelete.IsEnabled = true;
                                buttonDelete.Text      = viewModel.Delete;
                                MyReviewIndex          = Items.Count;
                            }
                            Items.Add(
                                new UserReviewModel()
                            {
                                Message    = UserReview.Message,
                                Karma      = UserReview.Karma,
                                Username   = UserReview.Username,
                                PostDate   = UserReview.PostDate,
                                UserReview = UserReview,
                                User       = users[UserReview.Username]
                            });
                        });
                    }
                    else
                    {
                        DisplayAlert("Klaida", "Nepavyko įkelti atsiliepimų", "Tęsti");
                    }
                });
            };
            userReviewGetter.Get(viewModel.User.Username);
        }
Ejemplo n.º 3
0
        public void UserReviewFullTest()
        {
            LocalUser user         = UnitTestAuth.Login();
            var       getStatus    = UserReviewsGetStatus.UnknownError;
            var       postStatus   = UserReviewManageStatus.UnknownError;
            var       removeStatus = UserReviewManageStatus.UnknownError;
            bool      done         = false;

            UserReview                review      = null;
            List <UserReview>         userReviews = null;
            Dictionary <String, User> users       = null;
            var random  = new Random();
            var message = random.Next().ToString();

            var getter = UserReviewSystemManager.NewUserReviewGetter();

            getter.Result += (_status, _userReviews, _users) => {
                getStatus   = _status;
                userReviews = _userReviews;
                users       = _users;
                done        = true;
            };

            var poster = UserReviewSystemManager.NewUserReviewPoster();

            poster.Result += (_status, _review) =>
            {
                postStatus = _status;
                review     = _review;
                done       = true;
            };

            var remover = UserReviewSystemManager.NewUserReviewRemover();

            remover.Result += (_status, _review) =>
            {
                removeStatus = _status;
                review       = _review;
                done         = true;
            };
            /// Siunčiam review
            done = false;
            poster.Post(new UserReview
            {
                Username = "******",
                Message  = message,
                Karma    = 1
            });
            while (!done)
            {
            }
            Assert.AreEqual(postStatus, UserReviewManageStatus.Success);
            Assert.AreNotEqual(review, null);
            ///
            /// Gaunam reviews ir patikrinam ar esam sąraše
            done = false;
            getter.Get("test4", true);
            while (!done)
            {
            }
            Assert.AreEqual(getStatus, UserReviewsGetStatus.Success);
            Assert.AreNotEqual(users, null);
            Assert.AreNotEqual(users[user.Username], null);
            Assert.AreNotEqual(userReviews, null);
            Assert.AreNotEqual(userReviews.Find((_review) => _review.Username == user.Username && _review.Message == message), null);
            ///
            /// Trinam review
            done = false;
            remover.Remove(new UserReview
            {
                Username = "******",
            });
            while (!done)
            {
            }
            Assert.AreEqual(removeStatus, UserReviewManageStatus.Success);
            Assert.AreNotEqual(review, null);
            ///

            /// Gaunam reviews ir patikrinam ar nesam sąraše
            done = false;
            getter.Get("test4", true);
            while (!done)
            {
            }
            Assert.AreEqual(getStatus, UserReviewsGetStatus.Success);
            Assert.AreNotEqual(users, null);
            Assert.AreNotEqual(userReviews, null);
            Assert.AreEqual(userReviews.Find((_review) => _review.Username == user.Username && _review.Message == message), null);
            ///
        }