aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-02-13 16:20:18 +0200
committertranstrike <transtrike@gmail.com>2021-02-13 16:20:18 +0200
commit98e17766b203734a1817eed94338e2d25f4395f7 (patch)
tree1266385a56cba56fd55c7faf661dd844bbdf5705 /src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs
parent1ab34accfda22ee3ce5c7700e3b97ff3e932d649 (diff)
downloadDevHive-98e17766b203734a1817eed94338e2d25f4395f7.tar
DevHive-98e17766b203734a1817eed94338e2d25f4395f7.tar.gz
DevHive-98e17766b203734a1817eed94338e2d25f4395f7.zip
Project Restructure P.1
Diffstat (limited to 'src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs')
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs b/src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs
deleted file mode 100644
index 9cbb43b..0000000
--- a/src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using DevHive.Data.Models;
-using DevHive.Data.Repositories;
-using Microsoft.EntityFrameworkCore;
-using NUnit.Framework;
-
-namespace DevHive.Data.Tests
-{
- [TestFixture]
- public class CommentRepositoryTests
- {
- private const string COMMENT_MESSAGE = "Comment message";
-
- protected DevHiveContext Context { get; set; }
-
- protected CommentRepository CommentRepository { get; set; }
-
- #region Setups
- [SetUp]
- public void Setup()
- {
- var optionsBuilder = new DbContextOptionsBuilder<DevHiveContext>()
- .UseInMemoryDatabase(databaseName: "DevHive_Test_Database");
-
- this.Context = new DevHiveContext(optionsBuilder.Options);
-
- CommentRepository = new CommentRepository(Context);
- }
-
- [TearDown]
- public void TearDown()
- {
- this.Context.Database.EnsureDeleted();
- }
- #endregion
-
- #region GetCommentByIssuerAndTimeCreatedAsync
- [Test]
- public async Task GetCommentByCreatorAndTimeCreatedAsync_ReturnsTheCorrectComment_IfItExists()
- {
- Comment comment = await this.AddEntity();
-
- Comment resultComment = await this.CommentRepository.GetCommentByIssuerAndTimeCreatedAsync(comment.Creator.Id, comment.TimeCreated);
-
- Assert.AreEqual(comment.Id, resultComment.Id, "GetCommentByIssuerAndTimeCreatedAsync does not return the corect comment when it exists");
- }
-
- [Test]
- public async Task GetPostByCreatorAndTimeCreatedAsync_ReturnsNull_IfThePostDoesNotExist()
- {
- Comment comment = await this.AddEntity();
-
- Comment resultComment = await this.CommentRepository.GetCommentByIssuerAndTimeCreatedAsync(Guid.Empty, DateTime.Now);
-
- Assert.IsNull(resultComment, "GetCommentByIssuerAndTimeCreatedAsync does not return null when the comment does not exist");
- }
- #endregion
-
- #region DoesCommentExist
- [Test]
- public async Task DoesCommentExist_ReturnsTrue_WhenTheCommentExists()
- {
- Comment comment = await this.AddEntity();
-
- bool result = await this.CommentRepository.DoesCommentExist(comment.Id);
-
- Assert.IsTrue(result, "DoesCommentExist does not return true whenm the Comment exists");
- }
-
- [Test]
- public async Task DoesCommentExist_ReturnsFalse_WhenTheCommentDoesNotExist()
- {
- bool result = await this.CommentRepository.DoesCommentExist(Guid.Empty);
-
- Assert.IsFalse(result, "DoesCommentExist does not return false whenm the Comment" +
- " does not exist");
- }
- #endregion
-
- #region HelperMethods
- private async Task<Comment> AddEntity(string name = COMMENT_MESSAGE)
- {
- User creator = new User { Id = Guid.NewGuid() };
- Comment comment = new Comment
- {
- Message = COMMENT_MESSAGE,
- Creator = creator,
- TimeCreated = DateTime.Now
- };
-
- this.Context.Comments.Add(comment);
- await this.Context.SaveChangesAsync();
-
- return comment;
- }
- #endregion
- }
-}