aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 18:56:25 +0300
committerGitHub <noreply@github.com>2021-04-09 18:56:25 +0300
commitd4134f3d873f220829d30170307f6415d493536c (patch)
tree11edb6b9df3106354eaeee01d532065203c34ff2
parent2fa6431d32c31a683b12eb2f00249416e5d87bbf (diff)
parentf1814e00c5416fd329880c6549ddc7a903a1a32c (diff)
downloadDevHive-d4134f3d873f220829d30170307f6415d493536c.tar
DevHive-d4134f3d873f220829d30170307f6415d493536c.tar.gz
DevHive-d4134f3d873f220829d30170307f6415d493536c.zip
Merge pull request #27 from Team-Kaleidoscope/unit_tests
Unit tests
-rw-r--r--src/Data/DevHive.Data.Tests/CommentRepository.Tests.cs77
-rw-r--r--src/Data/DevHive.Data.Tests/FeedRepository.Tests.cs69
-rw-r--r--src/Data/DevHive.Data.Tests/LenguageRepository.Tests.cs19
-rw-r--r--src/Data/DevHive.Data.Tests/RatingRepository.Tests.cs2
-rw-r--r--src/Data/DevHive.Data.Tests/RoleRepository.Tests.cs120
-rw-r--r--src/Data/DevHive.Data.Tests/UserRepositoryTests.cs265
-rw-r--r--src/Services/DevHive.Services.Tests/PostService.Tests.cs3
7 files changed, 149 insertions, 406 deletions
diff --git a/src/Data/DevHive.Data.Tests/CommentRepository.Tests.cs b/src/Data/DevHive.Data.Tests/CommentRepository.Tests.cs
index 0aa22bc..004d418 100644
--- a/src/Data/DevHive.Data.Tests/CommentRepository.Tests.cs
+++ b/src/Data/DevHive.Data.Tests/CommentRepository.Tests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using DevHive.Data.Models;
using DevHive.Data.Repositories;
@@ -14,7 +15,7 @@ namespace DevHive.Data.Tests
private DevHiveContext _context;
private CommentRepository _commentRepository;
- #region Setups
+ #region SetUp
[SetUp]
public void Setup()
{
@@ -33,6 +34,59 @@ namespace DevHive.Data.Tests
}
#endregion
+ #region GetByIdAsync
+ [Test]
+ public async Task GetByIdAsync_ReturnsTheCorrectComment_IfItExists()
+ {
+ Comment comment = await this.AddEntity();
+
+ Comment resultComment = await this._commentRepository.GetByIdAsync(comment.Id);
+
+ Assert.AreEqual(comment.Id, resultComment.Id, "GetByIdAsync does not return the correct comment when it exists.");
+ }
+
+ [Test]
+ public async Task GetByIdAsync_ReturnsNull_IfCommentDoesNotExist()
+ {
+ Comment resultComment = await this._commentRepository.GetByIdAsync(Guid.Empty);
+
+ Assert.IsNull(resultComment, "GetByIdAsync does not return null when the comment does not exist");
+ }
+ #endregion
+
+ #region GetPostComments
+ [Test]
+ public async Task GetPostComments_ReturnsAllCommentsForPost_IfAnyExist()
+ {
+ List<Comment> comments = new List<Comment>
+ {
+ new Comment(),
+ new Comment(),
+ new Comment()
+ };
+ Post post = new Post
+ {
+ Id = Guid.NewGuid(),
+ Comments = comments
+ };
+
+ this._context.Posts.Add(post);
+ await this._context.SaveChangesAsync();
+
+ List<Comment> resultComments = await this._commentRepository.GetPostComments(post.Id);
+
+ Assert.AreEqual(comments.Count, resultComments.Count, "GetPostComments does not return the comments for a given post correctly");
+ }
+
+ [Test]
+ public async Task GetPostComments_ReturnsEmptyList_WhenPostDoesNotExist()
+ {
+ List<Comment> resultComments = await this._commentRepository.GetPostComments(Guid.Empty);
+
+ Assert.IsEmpty(resultComments, "GetPostComments does not return empty string when post does not exist");
+ }
+ #endregion
+
#region GetCommentByIssuerAndTimeCreatedAsync
[Test]
public async Task GetCommentByCreatorAndTimeCreatedAsync_ReturnsTheCorrectComment_IfItExists()
@@ -47,14 +101,30 @@ namespace DevHive.Data.Tests
[Test]
public async Task GetPostByCreatorAndTimeCreatedAsync_ReturnsNull_IfThePostDoesNotExist()
{
- 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 EditAsync
+ [Test]
+ public async Task EditAsync_ReturnsTrue_WhenCommentIsUpdatedSuccessfully()
+ {
+ string newMessage = "New message!";
+ Comment comment = await this.AddEntity();
+ Comment updatedComment = new Comment
+ {
+ Id = comment.Id,
+ Message = newMessage
+ };
+
+ bool result = await this._commentRepository.EditAsync(comment.Id, updatedComment);
+
+ Assert.IsTrue(result, "EditAsync does not return true when comment is updated successfully");
+ }
+ #endregion
+
#region DoesCommentExist
[Test]
public async Task DoesCommentExist_ReturnsTrue_WhenTheCommentExists()
@@ -82,6 +152,7 @@ namespace DevHive.Data.Tests
User creator = new() { Id = Guid.NewGuid() };
Comment comment = new()
{
+ Id = Guid.NewGuid(),
Message = COMMENT_MESSAGE,
Creator = creator,
TimeCreated = DateTime.Now
diff --git a/src/Data/DevHive.Data.Tests/FeedRepository.Tests.cs b/src/Data/DevHive.Data.Tests/FeedRepository.Tests.cs
index f54e89d..5d66bfc 100644
--- a/src/Data/DevHive.Data.Tests/FeedRepository.Tests.cs
+++ b/src/Data/DevHive.Data.Tests/FeedRepository.Tests.cs
@@ -11,6 +11,9 @@ namespace DevHive.Data.Tests
[TestFixture]
public class FeedRepositoryTests
{
+ private const int PAGE_NUMBER = 1;
+ private const int PAGE_SIZE = 10;
+
private DevHiveContext _context;
private FeedRepository _feedRepository;
@@ -37,45 +40,66 @@ namespace DevHive.Data.Tests
[Test]
public async Task GetFriendsPosts_ReturnsListOfPosts_WhenTheyExist()
{
- User dummyUser = CreateDummyUser();
+ User dummyUser = this.CreateDummyUser();
+ dummyUser.Posts = await this.CreateDummyPosts(dummyUser);
List<User> friendsList = new()
{
dummyUser
};
- DateTime dateTime = new(3000, 05, 09, 9, 15, 0);
- Console.WriteLine(dateTime.ToFileTime());
-
- const int PAGE_NUMBER = 1;
- const int PAGE_SIZE = 10;
+ DateTime dateTime = DateTime.Now;
List<Post> resultList = await this._feedRepository.GetFriendsPosts(friendsList, dateTime, PAGE_NUMBER, PAGE_SIZE);
- Assert.GreaterOrEqual(2, resultList.Count, "GetFriendsPosts does not return all correct posts");
+ Assert.GreaterOrEqual(resultList.Count, dummyUser.Posts.Count, "GetFriendsPosts does not return the posts corrtrectly");
}
[Test]
- public async Task GetFriendsPosts_ReturnsNull_WhenNoSuitablePostsExist()
+ public async Task GetFriendsPosts_ReturnsEmptyList_WhenNoSuitablePostsExist()
{
- User dummyUser = CreateDummyUser();
+ User dummyUser = this.CreateDummyUser();
List<User> friendsList = new()
{
dummyUser
};
- DateTime dateTime = new(3000, 05, 09, 9, 15, 0);
-
- const int PAGE_NUMBER = 1;
- const int PAGE_SIZE = 10;
+ DateTime dateTime = DateTime.Now;
List<Post> resultList = await this._feedRepository.GetFriendsPosts(friendsList, dateTime, PAGE_NUMBER, PAGE_SIZE);
- Assert.LessOrEqual(0, resultList.Count, "GetFriendsPosts does not return all correct posts");
+ Assert.LessOrEqual(resultList.Count, 0, "GetFriendsPosts does not return all correct posts");
+ }
+ #endregion
+
+ #region GetUsersPosts
+ [Test]
+ public async Task GetUsersPosts_ReturnsAllPostsOfTheUser_IfAnyExist()
+ {
+ User dummyUser = this.CreateDummyUser();
+ HashSet<Post> posts = await this.CreateDummyPosts(dummyUser);
+
+ DateTime dateTime = DateTime.Now;
+
+ List<Post> resultList = await this._feedRepository.GetUsersPosts(dummyUser, dateTime, PAGE_NUMBER, PAGE_SIZE);
+
+ Assert.GreaterOrEqual(resultList.Count, posts.Count, "GetUsersPosts does not return the posts corrtrectly");
+ }
+
+ [Test]
+ public async Task GetUsersPosts_ReturnsEmptyList_WhenNoSuitablePostsExist()
+ {
+ User dummyUser = this.CreateDummyUser();
+
+ DateTime dateTime = DateTime.Now;
+
+ List<Post> resultList = await this._feedRepository.GetUsersPosts(dummyUser, dateTime, PAGE_NUMBER, PAGE_SIZE);
+
+ Assert.LessOrEqual(resultList.Count, 0, "GetUsersPosts does not return empty list when no suitable posts exist");
}
#endregion
#region HelperMethods
- private static User CreateDummyUser()
+ private User CreateDummyUser()
{
HashSet<Role> roles = new()
{
@@ -96,6 +120,21 @@ namespace DevHive.Data.Tests
Roles = roles
};
}
+
+ private async Task<HashSet<Post>> CreateDummyPosts(User user)
+ {
+ HashSet<Post> posts = new HashSet<Post>
+ {
+ new Post { Creator = user, TimeCreated = DateTime.Now },
+ new Post{ Creator = user, TimeCreated = DateTime.Now },
+ new Post{ Creator = user, TimeCreated = DateTime.Now }
+ };
+
+ await this._context.Posts.AddRangeAsync(posts);
+ await this._context.SaveChangesAsync();
+
+ return posts;
+ }
#endregion
}
}
diff --git a/src/Data/DevHive.Data.Tests/LenguageRepository.Tests.cs b/src/Data/DevHive.Data.Tests/LenguageRepository.Tests.cs
index 3bb9400..c7d4dc7 100644
--- a/src/Data/DevHive.Data.Tests/LenguageRepository.Tests.cs
+++ b/src/Data/DevHive.Data.Tests/LenguageRepository.Tests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DevHive.Data.Models;
@@ -56,6 +57,20 @@ namespace DevHive.Data.Tests
}
#endregion
+ #region GetLanguages
+ [Test]
+ public async Task GetLanguages_ReturnsAllLanguages()
+ {
+ await this.AddEntity();
+ await this.AddEntity("secondLanguage");
+ await this.AddEntity("thirdLanguage");
+
+ HashSet<Language> languages = this._languageRepository.GetLanguages();
+
+ Assert.GreaterOrEqual(languages.Count, 3, "GetLanguages does not get all Languages");
+ }
+ #endregion
+
#region DoesLanguageExistAsync
[Test]
public async Task DoesLanguageExist_ReturnsTrue_IfIdExists()
@@ -106,10 +121,12 @@ namespace DevHive.Data.Tests
{
Language language = new()
{
+ Id = Guid.NewGuid(),
Name = name
};
- await this._languageRepository.AddAsync(language);
+ await this._context.Languages.AddAsync(language);
+ await this._context.SaveChangesAsync();
}
#endregion
}
diff --git a/src/Data/DevHive.Data.Tests/RatingRepository.Tests.cs b/src/Data/DevHive.Data.Tests/RatingRepository.Tests.cs
index 2da90d9..29091d7 100644
--- a/src/Data/DevHive.Data.Tests/RatingRepository.Tests.cs
+++ b/src/Data/DevHive.Data.Tests/RatingRepository.Tests.cs
@@ -9,7 +9,7 @@ using System.Collections.Generic;
namespace DevHive.Data.Tests
{
- [TestFixture]
+ [TestFixture]
public class RatingRepositoryTests
{
private DevHiveContext _context;
diff --git a/src/Data/DevHive.Data.Tests/RoleRepository.Tests.cs b/src/Data/DevHive.Data.Tests/RoleRepository.Tests.cs
deleted file mode 100644
index 7a248d3..0000000
--- a/src/Data/DevHive.Data.Tests/RoleRepository.Tests.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using DevHive.Data.Models;
-using DevHive.Data.Repositories;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Moq;
-using NUnit.Framework;
-
-namespace DevHive.Data.Tests
-{
- [TestFixture]
- public class RoleRepositoryTests
- {
- // private const string ROLE_NAME = "Role test name";
- // private DevHiveContext _context;
- // private RoleRepository _roleRepository;
- //
- // #region Setups
- // [SetUp]
- // public void Setup()
- // {
- // DbContextOptionsBuilder<DevHiveContext> optionsBuilder = new DbContextOptionsBuilder<DevHiveContext>()
- // .UseInMemoryDatabase(databaseName: "DevHive_Test_Database");
- //
- // this._context = new DevHiveContext(optionsBuilder.Options);
- //
- // Mock<RoleManager<Role>> roleManagerMock = new();
- // this._roleRepository = new(this._context, roleManagerMock.Object);
- // }
- //
- // [TearDown]
- // public void TearDown()
- // {
- // _ = this._context.Database.EnsureDeleted();
- // }
- // #endregion
- //
- // #region GetByNameAsync
- // [Test]
- // public async Task GetByNameAsync_ReturnsTheRole_WhenItExists()
- // {
- // Role role = await this.AddEntity();
- //
- // Role resultRole = await this._roleRepository.GetByNameAsync(role.Name);
- //
- // Assert.AreEqual(role.Id, resultRole.Id, "GetByNameAsync does not return the correct role");
- // }
- //
- // [Test]
- // public async Task GetByNameAsync_ReturnsNull_WhenTheRoleDoesNotExist()
- // {
- // Role resultRole = await this._roleRepository.GetByNameAsync(ROLE_NAME);
- //
- // Assert.IsNull(resultRole, "GetByNameAsync does not return when the role does not exist");
- // }
- // #endregion
- //
- // #region DoesNameExist
- // [Test]
- // public async Task DoesNameExist_ReturnsTrue_WhenTheNameExists()
- // {
- // Role role = await this.AddEntity();
- //
- // bool result = await this._roleRepository.DoesNameExist(role.Name);
- //
- // Assert.IsTrue(result, "DoesNameExist returns false when the role name exist");
- // }
- //
- // [Test]
- // public async Task DoesNameExist_ReturnsFalse_WhenTheNameDoesNotExist()
- // {
- // bool result = await this._roleRepository.DoesNameExist(ROLE_NAME);
- //
- // Assert.IsFalse(result, "DoesNameExist returns false when the role name exist");
- // }
- // #endregion
- //
- // #region DoesRoleExist
- // [Test]
- // public async Task DoesRoleExist_ReturnsTrue_IfIdExists()
- // {
- // _ = await this.AddEntity();
- // Role role = this._context.Roles.Where(x => x.Name == ROLE_NAME).AsEnumerable().FirstOrDefault();
- // Guid id = role.Id;
- //
- // bool result = await this._roleRepository.DoesRoleExist(id);
- //
- // Assert.IsTrue(result, "DoesRoleExistAsync returns flase when role exists");
- // }
- //
- // [Test]
- // public async Task DoesRoleExist_ReturnsFalse_IfIdDoesNotExists()
- // {
- // Guid id = Guid.NewGuid();
- //
- // bool result = await this._roleRepository.DoesRoleExist(id);
- //
- // Assert.IsFalse(result, "DoesRoleExist returns true when role does not exist");
- // }
- // #endregion
- //
- // #region HelperMethods
- // private async Task<Role> AddEntity(string name = ROLE_NAME)
- // {
- // Role role = new()
- // {
- // Id = Guid.NewGuid(),
- // Name = name
- // };
- //
- // _ = this._context.Roles.Add(role);
- // _ = await this._context.SaveChangesAsync();
- //
- // return role;
- // }
- // #endregion
- }
-}
diff --git a/src/Data/DevHive.Data.Tests/UserRepositoryTests.cs b/src/Data/DevHive.Data.Tests/UserRepositoryTests.cs
deleted file mode 100644
index e8fc034..0000000
--- a/src/Data/DevHive.Data.Tests/UserRepositoryTests.cs
+++ /dev/null
@@ -1,265 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using DevHive.Data.Models;
-using DevHive.Data.Repositories;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
-using Moq;
-using NUnit.Framework;
-
-namespace DevHive.Data.Tests
-{
- [TestFixture]
- public class UserRepositoryTests
- {
- // private DevHiveContext _context;
- // private UserRepository _userRepository;
- //
- // #region Setups
- // [SetUp]
- // public void Setup()
- // {
- // DbContextOptionsBuilder<DevHiveContext> options = new DbContextOptionsBuilder<DevHiveContext>()
- // .UseInMemoryDatabase("DevHive_UserRepository_Database");
- // this._context = new DevHiveContext(options.Options);
- //
- // Guid userId = Guid.NewGuid();
- // Mock<IUserStore<User>> userStore = new();
- // userStore.Setup(x => x.FindByIdAsync(userId.ToString(), CancellationToken.None))
- // .ReturnsAsync(new User()
- // {
- // Id = userId,
- // UserName = "test",
- // });
- // Mock<UserManager<User>> userManagerMock = new(userStore.Object, null, null, null, null, null, null, null, null);
- //
- // Guid roleId = Guid.NewGuid();
- // Mock<IRoleStore<Role>> roleStore = new();
- // roleStore.Setup(x => x.FindByIdAsync(roleId.ToString(), CancellationToken.None))
- // .ReturnsAsync(new Role()
- // {
- // Id = roleId,
- // Name = "test",
- // });
- // Mock<RoleManager<Role>> roleManagerMock = new(roleStore.Object, null, null, null, null);
- // this._userRepository = new(this._context, userManagerMock.Object, roleManagerMock.Object);
- // }
- //
- // [TearDown]
- // public async Task Teardown()
- // {
- // _ = await this._context.Database.EnsureDeletedAsync();
- // }
- // #endregion
- //
- // #region EditAsync
- // [Test]
- // public async Task EditAsync_ReturnsTrue_WhenUserIsUpdatedSuccessfully()
- // {
- // User oldUser = CreateDummyUser();
- // _ = this._context.Users.Add(oldUser);
- // _ = await this._context.SaveChangesAsync();
- //
- // oldUser.UserName = "SuperSecretUserName";
- // bool result = await this._userRepository.EditAsync(oldUser.Id, oldUser);
- //
- // Assert.IsTrue(result, "EditAsync does not return true when User is updated successfully");
- // }
- // #endregion
- //
- // #region GetByIdAsync
- // [Test]
- // public async Task GetByIdAsync_ReturnsTheUse_WhenItExists()
- // {
- // User dummyUserOne = CreateDummyUser();
- // _ = await this._userRepository.AddAsync(dummyUserOne);
- //
- // User resultUser = await this._userRepository.GetByIdAsync(dummyUserOne.Id);
- //
- // Assert.AreEqual(dummyUserOne.UserName, resultUser.UserName);
- // }
- //
- // [Test]
- // public async Task GetByIdAsync_ReturnsNull_WhenUserDoesNotExist()
- // {
- // Guid id = Guid.NewGuid();
- //
- // User resultUser = await this._userRepository.GetByIdAsync(id);
- //
- // Assert.IsNull(resultUser);
- // }
- // #endregion
- //
- // #region GetByUsernameAsync
- // [Test]
- // public async Task GetByUsernameAsync_ReturnsUserFromDatabase_WhenItExists()
- // {
- // //Arrange
- // User dummyUser = CreateDummyUser();
- // _ = await this._userRepository.AddAsync(dummyUser);
- // string username = dummyUser.UserName;
- //
- // //Act
- // User user = await this._userRepository.GetByUsernameAsync(username);
- //
- // //Assert
- // Assert.AreEqual(dummyUser.Id, user.Id, "Method doesn't get the proper user from database");
- // }
- //
- // [Test]
- // public async Task GetByUsernameAsync_ReturnsNull_WhenUserDoesNotExist()
- // {
- // //Act
- // User user = await this._userRepository.GetByUsernameAsync(null);
- //
- // //Assert
- // Assert.IsNull(user, "Method returns user when it does not exist");
- // }
- // #endregion
- //
- // #region DoesUserExistAsync
- // [Test]
- // public async Task DoesUserExistAsync_ReturnsTrue_WhenUserExists()
- // {
- // User dummyUser = CreateDummyUser();
- // _ = this._context.Users.Add(dummyUser);
- // _ = await this._context.SaveChangesAsync();
- //
- // bool result = await this._userRepository.DoesUserExistAsync(dummyUser.Id);
- //
- // Assert.IsTrue(result, "DoesUserExistAsync does not return true when user exists");
- // }
- //
- // [Test]
- // public async Task DoesUserExistAsync_ReturnsFalse_WhenUserDoesNotExist()
- // {
- // Guid id = Guid.NewGuid();
- //
- // bool result = await this._userRepository.DoesUserExistAsync(id);
- //
- // Assert.IsFalse(result, "DoesUserExistAsync does not return false when user does not exist");
- // }
- // #endregion
- //
- // #region DoesUserNameExistAsync
- // [Test]
- // public async Task DoesUsernameExistAsync_ReturnsTrue_WhenUserWithTheNameExists()
- // {
- // User dummyUser = CreateDummyUser();
- // _ = this._context.Users.Add(dummyUser);
- // _ = await this._context.SaveChangesAsync();
- //
- // bool result = await this._userRepository.DoesUsernameExistAsync(dummyUser.UserName);
- //
- // Assert.IsTrue(result, "DoesUserNameExistAsync does not return true when username exists");
- // }
- //
- // [Test]
- // public async Task DoesUsernameExistAsync_ReturnsFalse_WhenUserWithTheNameDoesNotExist()
- // {
- // string userName = "Fake name";
- //
- // bool result = await this._userRepository.DoesUsernameExistAsync(userName);
- //
- // Assert.IsFalse(result, "DoesUserNameExistAsync does not return false when username does not exist");
- // }
- // #endregion
- //
- // #region DoesEmailExistAsync
- // [Test]
- // public async Task DoesEmailExistAsync_ReturnsTrue_WhenUserWithTheEmailExists()
- // {
- // User dummyUser = CreateDummyUser();
- // _ = this._context.Users.Add(dummyUser);
- // _ = await this._context.SaveChangesAsync();
- //
- // bool result = await this._userRepository.DoesEmailExistAsync(dummyUser.Email);
- //
- // Assert.IsTrue(result, "DoesUserNameExistAsync does not return true when email exists");
- // }
- //
- // [Test]
- // public async Task DoesEmailExistAsync_ReturnsFalse_WhenUserWithTheEmailDoesNotExist()
- // {
- // string email = "Fake email";
- //
- // bool result = await this._userRepository.DoesEmailExistAsync(email);
- //
- // Assert.IsFalse(result, "DoesUserNameExistAsync does not return false when email does not exist");
- // }
- // #endregion
- //
- // #region DoesUserHaveThisUsernameAsync
- // [Test]
- // public async Task DoesUserHaveThisUsername_ReturnsTrue_WhenUserHasTheGivenUsername()
- // {
- // User dummyUser = CreateDummyUser();
- // _ = this._context.Users.Add(dummyUser);
- // _ = await this._context.SaveChangesAsync();
- //
- // bool result = await this._userRepository.DoesUserHaveThisUsernameAsync(dummyUser.Id, dummyUser.UserName);
- //
- // Assert.IsTrue(result, "DoesUserHaveThisUsernameAsync does not return true when the user has the given name");
- // }
- //
- // [Test]
- // public async Task DoesUserHaveThisUsername_ReturnsFalse_WhenUserDoesntHaveTheGivenUsername()
- // {
- // string username = "Fake username";
- // User dummyUser = CreateDummyUser();
- // _ = this._context.Users.Add(dummyUser);
- // _ = await this._context.SaveChangesAsync();
- //
- // bool result = await this._userRepository.DoesUserHaveThisUsernameAsync(dummyUser.Id, username);
- //
- // Assert.IsFalse(result, "DoesUserNameExistAsync does not return false when user doesnt have the given name");
- // }
- // #endregion
- //
- // #region HelperMethods
- // private static User CreateDummyUser()
- // {
- // HashSet<Language> languages = new()
- // {
- // new Language()
- // {
- // Id = Guid.NewGuid(),
- // Name = "csharp"
- // },
- // };
- //
- // HashSet<Technology> technologies = new()
- // {
- // new Technology()
- // {
- // Id = Guid.NewGuid(),
- // Name = "ASP.NET Core"
- // },
- // };
- //
- // HashSet<Role> roles = new()
- // {
- // new Role()
- // {
- // Id = Guid.NewGuid(),
- // Name = Role.DefaultRole
- // },
- // };
- //
- // return new()
- // {
- // Id = Guid.NewGuid(),
- // UserName = "dummyUser",
- // FirstName = "Spas",
- // LastName = "Spasov",
- // Email = "abv@abv.bg",
- // Languages = languages,
- // Technologies = technologies,
- // Roles = roles
- // };
- // }
- // #endregion
- }
-}
diff --git a/src/Services/DevHive.Services.Tests/PostService.Tests.cs b/src/Services/DevHive.Services.Tests/PostService.Tests.cs
index 058485e..feab3be 100644
--- a/src/Services/DevHive.Services.Tests/PostService.Tests.cs
+++ b/src/Services/DevHive.Services.Tests/PostService.Tests.cs
@@ -124,7 +124,8 @@ namespace DevHive.Services.Tests
Post post = new Post
{
Message = MESSAGE,
- Creator = creator
+ Creator = creator,
+ Ratings = new List<Rating>()
};
ReadPostServiceModel readPostServiceModel = new ReadPostServiceModel
{