Exemple #1
0
        public void GetAllUsersTest()
        {
            var controller = getController();

            var data = controller.GetAllUsers(10, 1,
                                              ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(data);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(data);
            }

            var test = data.Count() > 1;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Exemple #2
0
        public void RunPupolate()
        {
            Pupolate();

            var repo = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            var data = repo.GetAllPost(userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.Null(data);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(data);
            }

            var test = data.Count() > 10;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Exemple #3
0
        public void Pupolate()
        {
            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userIds    = userList.Select(r => r.Id).ToArray();

            for (var i = 0; i < 1000; i++)
            {
                var post = new Post()
                {
                    UserId       = ArrayFaker.SelectFrom(userIds),
                    PostDetails  = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                    CreatedTime  = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                    LikedUserIds = ArrayFaker.SelectFrom(NumberFaker.Number(0, 5), userIds).ToList(),
                    Comments     = new List <Comment>()
                    {
                        new Comment()
                        {
                            CommentDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                            CreatedTime    =
                                DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                            UserId = ArrayFaker.SelectFrom(userIds),
                        },
                        new Comment()
                        {
                            CommentDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                            CreatedTime    =
                                DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                            UserId = ArrayFaker.SelectFrom(userIds),
                        }
                    }
                };
                postRepo.Add(post);
            }
        }
        public void CreatePostTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            var postId = postBll.CreatePost(new PostViewModel()
            {
                UserId      = userId,
                PostDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                CreatedTime =
                    DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotEmpty(postId);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(postId);
            }
        }
        public void GetAllPostsTest()
        {
            var controller = getController();

            IUserBLL userBll = new UserBLL();

            var userNames = ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul");

            var userId = userBll.GetAllUser(10, 1, userNames).First().Id;

            var data = controller.GetAllPosts(userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(data);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(data);
            }

            var test = data.Count() > 1;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
        public void DeletePostTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            var posts = postBll.GetAllPost(userId);

            var post = posts.First();

            var test = postBll.DeletePost(post.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var testNotExist = postBll.DeletePost(post.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testNotExist);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testNotExist);
            }
        }
Exemple #7
0
        public void Pupolate()
        {
            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, NameFaker.FirstName());

            var userIds = userList.Select(r => r.Id).ToArray();

            for (var i = 0; i < 1000; i++)
            {
                var friend = new Friend()
                {
                    FriendId   = ArrayFaker.SelectFrom(1, userIds).First(),
                    UserId     = ArrayFaker.SelectFrom(1, userIds).First(),
                    IsAccepted = BooleanFaker.Boolean()
                };
                friendRepo.Add(friend);
            }

            userList = controller.GetAllUsers(10, 1,
                                              ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            userIds = userList.Select(r => r.Id).ToArray();

            for (var i = 0; i < 10; i++)
            {
                var friend = new Friend()
                {
                    FriendId   = ArrayFaker.SelectFrom(1, userIds).First(),
                    UserId     = ArrayFaker.SelectFrom(1, userIds).First(),
                    IsAccepted = BooleanFaker.Boolean()
                };
                friendRepo.Add(friend);
            }
        }
Exemple #8
0
        public void RunPupolate()
        {
            Pupolate();

            var repo = new UserBLL();

            var data = repo.GetAllUser(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.Null(data);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(data);
            }

            var test = data.Count() > 10;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Exemple #9
0
 public static T[] SelectFrom <T>(int numElements, params T[] array)
 {
     T[] tArray = new T[numElements];
     while (numElements > 0)
     {
         tArray[numElements - 1] = ArrayFaker.SelectFrom <T>(array);
         numElements--;
     }
     return(tArray);
 }
        public void UpatePostTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            var userId = userList.First().Id;

            var userIds = userList.Select(r => r.Id).ToList();

            postBll.CreatePost(new PostViewModel()
            {
                UserId      = userId,
                PostDetails = TextFaker.Sentences(5),
                CreatedTime = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });

            var posts = postBll.GetAllPost(userId);

            var post = posts.First();

            var test = postBll.UpatePost(new PostViewModel()
            {
                Id           = post.Id,
                UserId       = post.UserId,
                PostDetails  = TextFaker.Sentences(NumberFaker.Number(5, 30)),
                LikedUserIds = userIds,
                CreatedTime  = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });


            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var updatedPost = postBll.GetPostByID(post.Id);

            var testNoOfUserLike = updatedPost.LikedUserIds.Count() == userId.Count();

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testNoOfUserLike);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testNoOfUserLike);
            }
        }
Exemple #11
0
        private UserController getController()
        {
            IUserBLL userBll = new UserBLL();

            var userNames = ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul");

            var userName = userBll.GetAllUser(10, 1, userNames).First().Id;
            var identity = new GenericIdentity(userName);

            Thread.CurrentPrincipal = new GenericPrincipal(identity, null);

            return(new UserController(userBll));
        }
Exemple #12
0
        public static string StreetName()
        {
            string[] strArray = new string[] { "Highland", "Hill", "Park", "Woodland", "Sunset", "Virginia" };
            string   str      = ArrayFaker.SelectFrom <string>(strArray);

            if (!BooleanFaker.Boolean())
            {
                string[] strArray1 = new string[] { "Adams", "Franklin", "Jackson", "Jefferson", "Lincoln", "Madison", "Washington", "Wilson" };
                return(string.Concat(ArrayFaker.SelectFrom <string>(strArray1), " ", str));
            }
            string[] strArray2 = new string[] { "Acacia", "Beech", "Birch", "Cedar", "Cherry", "Chestnut", "Elm", "Larch", "Laurel", "Linden", "Maple", "Oak", "Pine", "Rose", "Walnut", "Willow" };
            return(string.Concat(ArrayFaker.SelectFrom <string>(strArray2), " ", str));
        }
        public void AddCommentsTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            var posts = postBll.GetAllPost(userId);

            var test = posts.Any();

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var post = posts.First();

            post = postBll.GetPostByID(post.Id);

            var userIds = userList.Select(r => r.Id).ToArray();

            var comment = new CommentViewModel()
            {
                PostId         = post.Id,
                CommentDetails = TextFaker.Sentences(NumberFaker.Number(1, 25)),
                CreatedTime    =
                    DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture),
                UserId = ArrayFaker.SelectFrom(userIds)
            };

            postBll.AddComments(comment);

            var postWithComment = postBll.GetPostByID(post.Id);

            var testCommentInsert = post.Comments.Count() == postWithComment.Comments.Count() - 1;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testCommentInsert);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testCommentInsert);
            }
        }
        public void GetPostByIDTest()
        {
            var postBll = getBll();

            var controller = new UserController(new UserBLL());
            var userList   = controller.GetAllUsers(100, 1, ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));
            var userId     = userList.First().Id;

            postBll.CreatePost(new PostViewModel()
            {
                UserId      = userId,
                PostDetails = TextFaker.Sentences(5),
                CreatedTime = DateTimeFaker.DateTime().ToString(CultureInfo.InvariantCulture)
            });

            var posts = postBll.GetAllPost(userId);

            var post = posts.First();

            var foundPost = postBll.GetPostByID(post.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(foundPost);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(foundPost);
            }

            var test = foundPost.Id.Equals(post.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
        private PostController getController()
        {
            IUserBLL userBll   = new UserBLL();
            var      userNames = ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul");
            var      userVm    = userBll.GetAllUser(10, 1, userNames).First();

            var mockUserBll = new Mock <IUserBLL>();

            mockUserBll.Setup(c => c.GetUserByUserName(userVm.Id)).Returns(userVm);
            mockUserBll.Setup(c => c.GetUserById(userVm.Id)).Returns(userVm);

            userBll = mockUserBll.Object;

            IFriendBLL friendBll = new FriendBLL(userBll);
            IPostBLL   postBll   = new PostBLL(userBll, friendBll);

            var identity = new GenericIdentity(userVm.Id);

            Thread.CurrentPrincipal = new GenericPrincipal(identity, null);

            return(new PostController(postBll, userBll));
        }
Exemple #16
0
        public void GetUserByUserNameTest()
        {
            var userBll = new UserBLL();

            var name      = ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul");
            var foundUser = userBll.GetUserByUserName(name);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.Null(foundUser);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(foundUser);
            }

            var test = foundUser.FirstName.Equals(name);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            /*
             * var testSameId = foundUser.Id.Equals(user.Id);
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.True(testSameId);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testSameId);
             */
        }
Exemple #17
0
 public static string LastName()
 {
     string[] strArray = new string[] { "Abel", "Anderson", "Andrews", "Anthony", "Baker", "Brown", "Burrows", "Clark", "Clarke", "Clarkson", "Davidson", "Davies", "Davis", "Dent", "Edwards", "Garcia", "Grant", "Hall", "Harris", "Harrison", "Jackson", "Jeffries", "Jefferson", "Johnson", "Jones", "Kirby", "Kirk", "Lake", "Lee", "Lewis", "Martin", "Martinez", "Major", "Miller", "Moore", "Oates", "Peters", "Peterson", "Robertson", "Robinson", "Rodriguez", "Smith", "Smythe", "Stevens", "Taylor", "Thatcher", "Thomas", "Thompson", "Walker", "Washington", "White", "Williams", "Wilson", "Yorke" };
     return(ArrayFaker.SelectFrom <string>(strArray));
 }
        public void Friend_Suggestion_Test()
        {
            var repo = new FriendBLL(new UserBLL());

            var controller = new UserController(new UserBLL());

            var userList = controller.GetAllUsers(NumberFaker.Number(1, 10), NumberFaker.Number(1, 2),
                                                  ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            //Get Seven user to make friend
            var userIds = userList.Select(r => r.Id).Take(7).ToList();

            var userId = userIds.First();

            var friendId = userIds.Skip(1).First();

            //Test whether thay are friend or not
            var alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            friendId = userIds.Skip(2).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            friendId = userIds.Skip(3).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }


            friendId = userIds.Skip(4).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.Skip(1).First();

            friendId = userIds.Skip(2).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.Skip(5).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            friendId = userIds.Skip(3).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.Skip(4).First();

            friendId = userIds.Skip(6).First();

            //Test whether thay are friend or not
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            userId = userIds.First();

            // Get Suggested Friend of 'A' should found 'C' and 'G'

            var suggestedFriends = repo.GetFriendSuggestion(userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(suggestedFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(suggestedFriends);
            }

            var test = suggestedFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            var suggestedFriendIds = suggestedFriends.Select(r => r.UserId.Equals(userId) ? r.FriendId : r.UserId);

            test = suggestedFriendIds.Contains(userIds.Skip(5).First());

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            test = suggestedFriendIds.Contains(userIds.Skip(6).First());

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
        public void Find_Mutual_Friend_Test()
        {
            var repo = new FriendBLL(new UserBLL());

            var controller = new UserController(new UserBLL());

            var userList = controller.GetAllUsers(NumberFaker.Number(1, 10), NumberFaker.Number(1, 2),
                                                  ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            //Get three user to make friend
            var userId = userList.Select(r => r.Id).First();

            var friendId = userList.Where(r => r.Id != userId).Select(r => r.Id).First();

            //Test whether thay are friend or not

            var alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(userId, friendId);
                repo.AcceptFriendRequest(userId, friendId);
                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            var mutualFriend = userList.Where(r => r.Id != userId && r.Id != friendId).Select(r => r.Id).First();

            //Test whether thay are friend or not

            alreadyFriend = repo.IsExistsFriend(mutualFriend, friendId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(mutualFriend, friendId);
                repo.AcceptFriendRequest(mutualFriend, friendId);
                alreadyFriend = repo.IsExistsFriend(mutualFriend, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            //Test whether thay are friend or not

            alreadyFriend = repo.IsExistsFriend(mutualFriend, userId);

            if (!alreadyFriend)
            {
                // Make them friend
                repo.SendFriendRequest(mutualFriend, userId);
                repo.AcceptFriendRequest(mutualFriend, userId);
                alreadyFriend = repo.IsExistsFriend(mutualFriend, userId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            // Get Mutual friend -> Mr X and Mr Y found Mr. Z

            var mutualFriends = repo.GetMutualFriend(userId, mutualFriend);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            var test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Y and Mr X found Mr. Z

            mutualFriends = repo.GetMutualFriend(mutualFriend, userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Y and Mr Z found Mr. X

            mutualFriends = repo.GetMutualFriend(mutualFriend, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Z and Mr Y found Mr. X

            mutualFriends = repo.GetMutualFriend(friendId, mutualFriend);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr Z and Mr X found Mr. Y

            mutualFriends = repo.GetMutualFriend(friendId, userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Get Mutual friend -> Mr X and Mr Z found Mr. Y

            mutualFriends = repo.GetMutualFriend(friendId, userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(mutualFriends);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(mutualFriends);
            }

            test = mutualFriends.Count() > 0;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
        public void Send_And_Reject_Friend_Request_Test()
        {
            var repo = new FriendBLL(new UserBLL());

            var controller = new UserController(new UserBLL());

            var userList = controller.GetAllUsers(NumberFaker.Number(1, 10), NumberFaker.Number(1, 3),
                                                  ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            //Get two user to make friend
            var userId = userList.Select(r => r.Id).First();

            var friendId = userList.Where(r => r.Id != userId).Select(r => r.Id).First();

            //Test whether thay are friend or not

            var alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (alreadyFriend)
            {
                // They are friend so try to find who are not friend
                //userId = userList.Where(r => r.Id != userId).Select(r => r.Id).First();

                //friendId = userList.Where(r => r.Id != userId && r.Id != friendId).Select(r => r.Id).First();

                // Remove friend
                var removeThemFriend = repo.RemoveFriend(userId, friendId);

                if (TestingConfig.XUnit)
                {
                    Xunit.Assert.True(removeThemFriend);
                }
                else
                {
                    Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(removeThemFriend);
                }

                alreadyFriend = repo.IsExistsFriend(userId, friendId);
            }

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.False(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(alreadyFriend);
            }

            // Send friend request
            var test = repo.SendFriendRequest(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }

            // Now one send friend request to other
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(alreadyFriend);
            }

            /*
             * // Get request object to reject
             * var friend = repo.GetFriendRequest(userId, friendId);
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.NotNull(friend);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(friend);
             *
             * var testFriendIds = friend.UserId == userId && friend.FriendId == friendId;
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.True(test);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
             *
             * // Check friend request has been pending
             * var testPendingFriendRequest = friend.IsAccepted;
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.False(testPendingFriendRequest);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(testPendingFriendRequest);
             */

            // Check all request of a user
            var friendRequests = repo.GetAllFriendRequestsByUser(friendId);

            friendRequests = repo.GetAllFriendRequestsByUser(userId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.NotNull(friendRequests);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(friendRequests);
            }

            var testFriendRequests = friendRequests.Count() > 1;

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testFriendRequests);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testFriendRequests);
            }

            // Reject a request and make friend
            var rejectFriendRequest = repo.RejectFriendRequest(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(rejectFriendRequest);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(rejectFriendRequest);
            }

            /*
             * // Now no friend request
             * var friendInfo = repo.GetFriendRequest(userId, friendId);
             *
             * if (TestingConfig.XUnit)
             *  Xunit.Assert.Null(friendInfo);
             * else
             *  Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNull(friendInfo);
             */

            // The are not friend
            alreadyFriend = repo.IsExistsFriend(userId, friendId);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.False(alreadyFriend);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(alreadyFriend);
            }
        }
Exemple #21
0
 public static string City()
 {
     string[] strArray = new string[] { "Midway", "Mount", "Pleasant", "Greenwood", "Franklin", "Oak", "Grove", "Centerville", "Salem", "Georgetown", "Fairview", "Riverside", "Rotorua", "Tauranga", "Whakatane", "Taupo", "Wanganui", "Nababeep", "Aggeneys", "Pofadder", "Polokwane", "Bela", "Bela", "Goukamma", "Karatara", "Tswane", "Prieska", "Upington", "Hoopstad", "Bultfontein", "Wesselsbron", "Bothaville", "Trompsburg", "Henneman", "Musina", "Ogies", "Kgatlahong", "Tembisa", "Tekoza", "Sebokeng", "Muntaung", "Umnkomaaz" };
     return(ArrayFaker.SelectFrom <string>(strArray));
 }
Exemple #22
0
        public void GetUserByIdTest()
        {
            var userBll = new UserBLL();

            var users = userBll.GetAllUser(NumberFaker.Number(1, 10), NumberFaker.Number(1, 3), ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            var user = users.First();

            var foundUser = userBll.GetUserById(user.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.Null(foundUser);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(foundUser);
            }

            var testSameId = foundUser.Id.Equals(user.Id);

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(testSameId);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(testSameId);
            }
        }
Exemple #23
0
 public static string MaleFirstName()
 {
     string[] strArray = new string[] { "Adam", "Anthony", "Arthur", "Brian", "Charles", "Christopher", "Daniel", "David", "Donald", "Edgar", "Edward", "Edwin", "George", "Harold", "Herbert", "Hugh", "James", "Jason", "John", "Joseph", "Kenneth", "Kevin", "Marcus", "Mark", "Matthew", "Michael", "Paul", "Philip", "Richard", "Robert", "Roger", "Ronald", "Simon", "Steven", "Terry", "Thomas", "William" };
     return(ArrayFaker.SelectFrom <string>(strArray));
 }
Exemple #24
0
 public void ArrayFakerTest()
 {
     DisplayAndExecute(new Expression <Func <string> >[] {
         () => ArrayFaker.SelectFrom("one", "two", "three"),
     });
 }
Exemple #25
0
 public static string Domain()
 {
     string[] strArray = new string[] { "yahoo.com", "gmail.com", "privacy.net", "webmail.com", "msn.com", "hotmail.com", "example.com" };
     return(ArrayFaker.SelectFrom <string>(strArray));
 }
Exemple #26
0
 public static string Sentences(int numSentences)
 {
     string[] strArray = new string[] { "Lorem ipsum dolor sit amet  consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", "Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur", "Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum" };
     return(string.Join(". ", ArrayFaker.SelectFrom <string>(numSentences, strArray)));
 }
Exemple #27
0
 public static string FemaleFirstName()
 {
     string[] strArray = new string[] { "Alison", "Ann", "Anna", "Anne", "Barbara", "Betty", "Beryl", "Carol", "Charlotte", "Cheryl", "Deborah", "Diana", "Donna", "Dorothy", "Elizabeth", "Eve", "Felicity", "Fiona", "Helen", "Helena", "Jennifer", "Jessica", "Judith", "Karen", "Kimberly", "Laura", "Linda", "Lisa", "Lucy", "Margaret", "Maria", "Mary", "Michelle", "Nancy", "Patricia", "Polly", "Robyn", "Ruth", "Sandra", "Sarah", "Sharon", "Susan", "Tabitha", "Ursula", "Victoria", "Wendy" };
     return(ArrayFaker.SelectFrom <string>(strArray));
 }
Exemple #28
0
        public void GetAllUserTest()
        {
            var userBll = new UserBLL();

            var users = userBll.GetAllUser(NumberFaker.Number(1, 10), NumberFaker.Number(1, 3), ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"));

            var test = users.Any();

            if (TestingConfig.XUnit)
            {
                Xunit.Assert.True(test);
            }
            else
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(test);
            }
        }
Exemple #29
0
        public void Pupolate()
        {
            var user = new User()
            {
                UserName  = StringFaker.AlphaNumeric(12),
                FirstName = "Jahirul",
                LastName  = "Islam"
            };

            userRepo.Add(user);
            user = new User()
            {
                UserName  = StringFaker.AlphaNumeric(12),
                FirstName = "Monirul",
                LastName  = "Islam"
            };
            userRepo.Add(user);
            user = new User()
            {
                UserName  = StringFaker.AlphaNumeric(12),
                FirstName = "Aminul",
                LastName  = "Islam"
            };
            userRepo.Add(user);
            user = new User()
            {
                UserName  = StringFaker.AlphaNumeric(12),
                FirstName = "Fukrul",
                LastName  = "Islam"
            };
            userRepo.Add(user);

            user = new User()
            {
                UserName  = StringFaker.AlphaNumeric(12),
                FirstName = "Najrul",
                LastName  = "Islam"
            };
            userRepo.Add(user);

            user = new User()
            {
                UserName  = StringFaker.AlphaNumeric(12),
                FirstName = "Kamrul",
                LastName  = "Islam"
            };
            userRepo.Add(user);

            for (var i = 0; i < 1000; i++)
            {
                user = new User()
                {
                    UserName  = StringFaker.AlphaNumeric(12),
                    FirstName = NameFaker.FirstName(),
                    LastName  = NameFaker.LastName()
                };
                userRepo.Add(user);
            }
            for (var i = 0; i < 10; i++)
            {
                user = new User()
                {
                    UserName  = StringFaker.AlphaNumeric(12),
                    FirstName = ArrayFaker.SelectFrom("Jahirul", "Monirul", "Aminul", "Fukrul", "Najrul", "Kamrul"),
                    LastName  = ArrayFaker.SelectFrom("Islam", "Bhuiyan", "Khan", "")
                };
                userRepo.Add(user);
            }
        }
Exemple #30
0
 public static string Country()
 {
     string[] strArray = new string[] { "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Channel Islands", "Chile", "China", "Colombia", "Comoros", "Congo, Dem. Rep.", "Congo, Rep.", "Costa Rica", "Côte d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt, Arab Rep.", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Faeroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hong Kong, China", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Rep.", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Dem. Rep.", "Korea, Rep.", "Kuwait", "Kyrgyz Republic", "Lao PDR", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao, China", "Macedonia, FYR", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Fed. Sts.", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russian Federation", "Rwanda", "Samoa", "San Marino", "São Tomé and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "St. Kitts and Nevis", "St. Lucia", "St. Vincent and the Grenadines", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela, RB", "Vietnam", "Virgin Islands (U.S.)", "West Bank and Gaza", "Yemen, Rep.", "Zambia", "Zimbabwe" };
     return(ArrayFaker.SelectFrom <string>(strArray));
 }