예제 #1
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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
 public void DateTimeFakerTest()
 {
     DisplayAndExecute(new Expression <Func <DateTime> >[] {
         () => DateTimeFaker.DateTime(),
         () => DateTimeFaker.DateTime(DateTime.Parse("1980-5-13"), DateTime.Parse("2060-7-13")),
         () => DateTimeFaker.DateTimeBetweenDays(0, 30),
         () => DateTimeFaker.DateTimeBetweenDays(20),
         () => DateTimeFaker.DateTimeBetweenMonths(6, 0),
         () => DateTimeFaker.DateTimeBetweenMonths(9),
         () => DateTimeFaker.DateTimeBetweenYears(0, 1),
         () => DateTimeFaker.DateTimeBetweenYears(5),
         () => DateTimeFaker.BirthDay(33),
         () => DateTimeFaker.BirthDay()
     });
 }
예제 #6
0
        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);
            }
        }