Ejemplo n.º 1
0
        public async Task CanDelete_WithExistingCommentOnImagePostNotOwnedByUser_ReturnsFalse()
        {
            string  userEmail = "*****@*****.**";
            Comment comment   = new Comment()
            {
                ImagePost = new ImagePost()
            };
            ShowNTellDbContext context = GetDbContext();

            context.Add(comment);
            context.SaveChanges();

            bool actual = await _commentService.CanDelete(comment.Id, userEmail);

            Assert.IsFalse(actual);
        }
Ejemplo n.º 2
0
        public async Task GetByEmail_WithExistingEmail_ReturnsUserWithEmail()
        {
            string             expectedEmail = "*****@*****.**";
            ShowNTellDbContext context       = _contextFactory.CreateDbContext();

            context.Add(new User()
            {
                Email = expectedEmail
            });
            context.SaveChanges();

            User user = await _userService.GetByEmail(expectedEmail);

            string actualEmail = user.Email;

            Assert.AreEqual(expectedEmail, actualEmail);
        }
Ejemplo n.º 3
0
        public async Task IsCommentOwner_WithExistingCommentOwnedByUser_ReturnsTrue()
        {
            string  userEmail = "*****@*****.**";
            Comment comment   = new Comment()
            {
                User = new User {
                    Email = userEmail
                }
            };
            ShowNTellDbContext context = GetDbContext();

            context.Add(comment);
            context.SaveChanges();

            bool actual = await _commentService.IsCommentOwner(comment.Id, userEmail);

            Assert.IsTrue(actual);
        }
Ejemplo n.º 4
0
        public async Task GetByEmail_WithUserFollowingOthers_ReturnsUserWithFollows()
        {
            int expectedFollowingCount = 3;
            ShowNTellDbContext context = _contextFactory.CreateDbContext();

            context.Add(new User()
            {
                Email = string.Empty, Following = new List <Follow>()
                {
                    new Follow()
                    {
                        User = new User()
                        {
                            Email = "*****@*****.**"
                        }
                    },
                    new Follow()
                    {
                        User = new User()
                        {
                            Email = "*****@*****.**"
                        }
                    },
                    new Follow()
                    {
                        User = new User()
                        {
                            Email = "*****@*****.**"
                        }
                    }
                }
            });
            context.SaveChanges();

            User user = await _userService.GetByEmail(string.Empty);

            int actualFollowingCount = user.Following.Count;

            Assert.IsNotNull(user.Following);
            Assert.AreEqual(expectedFollowingCount, actualFollowingCount);
        }
Ejemplo n.º 5
0
        public void Create_WithExistingEmail_ThrowsArgumentExceptionForEmail()
        {
            string             expectedInvalidParamName = "email";
            string             existingEmail            = "*****@*****.**";
            ShowNTellDbContext context = _contextFactory.CreateDbContext();

            context.Add(new User()
            {
                Email = existingEmail
            });
            context.SaveChanges();
            User newUser = new User()
            {
                Email = existingEmail
            };

            ArgumentException exception = Assert.ThrowsAsync <ArgumentException>(() => _userService.Create(newUser));
            string            actualInvalidParamName = exception.ParamName;

            Assert.AreEqual(expectedInvalidParamName, actualInvalidParamName);
        }