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); }
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); }
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); }
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); }
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); }