diff options
| author | Kamen Mladenov <kamen.d.mladenov@protonmail.com> | 2021-04-09 19:51:35 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-09 19:51:35 +0300 |
| commit | 233f38915ba0079079233eff55434ef349c05c45 (patch) | |
| tree | 6c5f69017865bcab87355e910c87339453da1406 /src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs | |
| parent | f4a70c6430db923af9fa9958a11c2d6612cb52cc (diff) | |
| parent | a992357efcf1bc1ece81b95ecee5e05a0b73bfdc (diff) | |
| download | DevHive-233f38915ba0079079233eff55434ef349c05c45.tar DevHive-233f38915ba0079079233eff55434ef349c05c45.tar.gz DevHive-233f38915ba0079079233eff55434ef349c05c45.zip | |
Merge pull request #28 from Team-Kaleidoscope/devHEADv0.2mainheroku/main
Second stage: Complete
Diffstat (limited to 'src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs')
| -rw-r--r-- | src/DevHive.Tests/DevHive.Data.Tests/CommentRepository.Tests.cs | 99 |
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 - } -} |
