public void GetByWrongId_Null() { // Arrange CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext); Guid wrongId = default(Guid); CommentLike expectedCommentLikeFromDb = null; // Act CommentLike actualCommentLikeFromDb = commentLikeRepository.Get(wrongId); // Assert Assert.AreEqual(expectedCommentLikeFromDb, actualCommentLikeFromDb); }
public void GetById() { // Arrange CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext); Guid idToSearch = dbContext.CommentLike.First().Id; CommentLike expectedCommentLike = dbContext.CommentLike.Find(idToSearch); // Act CommentLike commentLikeFromDb = commentLikeRepository.Get(idToSearch); // Assert Assert.AreEqual(expectedCommentLike, commentLikeFromDb); }
public void GetFilterByIsLiked() { // Arrange CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext); int expectedCommentLikeWithLikeInDb = Resources.Classes.DbFiller.Instance.CommentLikeAmountWithLike; // Act CommentLike[] commentLikeFromDb = commentLikeRepository.Get(filter: commentLike => commentLike.IsLiked == true).ToArray(); int actualCommentLikeWithLikeInDb = commentLikeFromDb.Length; // Assertz Assert.AreEqual(expectedCommentLikeWithLikeInDb, actualCommentLikeWithLikeInDb); CollectionAssert.IsSubsetOf(commentLikeFromDb, dbContext.CommentLike.ToArray()); }
public void GetAll() { // Arrange CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext); int expectedCommentLikeInDb = Resources.Classes.DbFiller.Instance.CommentLikeAmount; // Act CommentLike[] commentLikeFromDb = commentLikeRepository.Get().ToArray(); int actualCommentLikeInDb = commentLikeFromDb.Length; // Assert Assert.AreEqual(expectedCommentLikeInDb, actualCommentLikeInDb); CollectionAssert.AreEquivalent(dbContext.CommentLike.ToArray(), commentLikeFromDb); }
public void GetOrder() { // Arrange CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext); int expectedCommentLikeInDb = Resources.Classes.DbFiller.Instance.CommentLikeAmount; // Act CommentLike[] commentLikeFromDb = commentLikeRepository.Get(orderBy: commentLike => commentLike.OrderBy(cl => cl.IsLiked)).ToArray(); int actualCommentLikeInDb = commentLikeFromDb.Length; // Assert Assert.AreEqual(expectedCommentLikeInDb, actualCommentLikeInDb); CollectionAssert.AreEqual(dbContext.CommentLike.OrderBy(cl => cl.IsLiked).ToArray(), commentLikeFromDb); }
public void GetFilterAndOrder() { // Arrange CommentLikeRepository commentLikeRepository = new CommentLikeRepository(dbContext); int expectedCommentLikeWithLikeInDb = Resources.Classes.DbFiller.Instance.CommentLikeAmountWithLike; CommentLike[] likesInDb = dbContext.CommentLike.Where(cl => cl.IsLiked == true).OrderByDescending(cl => cl.User.NickName).ToArray(); // Act CommentLike[] commentLikeFromDb = commentLikeRepository .Get(filter: cl => cl.IsLiked == true, orderBy: o => o.OrderByDescending(cl => cl.User.NickName)).ToArray(); int actualCommentLikeWithLikeInDb = commentLikeFromDb.Length; // Assert Assert.AreEqual(expectedCommentLikeWithLikeInDb, actualCommentLikeWithLikeInDb); CollectionAssert.AreEqual(likesInDb, commentLikeFromDb); }