aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/DevHive.Data/Interfaces/ILanguageRepository.cs13
-rw-r--r--src/DevHive.Data/Interfaces/IPostRepository.cs20
-rw-r--r--src/DevHive.Data/Interfaces/IRepository.cs (renamed from src/DevHive.Data/Repositories/IRepository.cs)2
-rw-r--r--src/DevHive.Data/Interfaces/IRoleRepository.cs15
-rw-r--r--src/DevHive.Data/Interfaces/ITechnologyRepository.cs13
-rw-r--r--src/DevHive.Data/Interfaces/IUserRepository.cs37
-rw-r--r--src/DevHive.Data/Repositories/LanguageRepository.cs4
-rw-r--r--src/DevHive.Data/Repositories/PostRepository.cs13
-rw-r--r--src/DevHive.Data/Repositories/RoleRepository.cs5
-rw-r--r--src/DevHive.Data/Repositories/TechnologyRepository.cs9
-rw-r--r--src/DevHive.Data/Repositories/UserRepository.cs7
-rw-r--r--src/DevHive.Services/Interfaces/ILanguageService.cs17
-rw-r--r--src/DevHive.Services/Interfaces/IPostService.cs24
-rw-r--r--src/DevHive.Services/Interfaces/IRoleService.cs17
-rw-r--r--src/DevHive.Services/Interfaces/ITechnologyService.cs17
-rw-r--r--src/DevHive.Services/Interfaces/IUserService.cs31
-rw-r--r--src/DevHive.Services/Services/LanguageService.cs22
-rw-r--r--src/DevHive.Services/Services/PostService.cs27
-rw-r--r--src/DevHive.Services/Services/RoleService.cs11
-rw-r--r--src/DevHive.Services/Services/TechnologyService.cs11
-rw-r--r--src/DevHive.Services/Services/UserService.cs22
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/TechnologyService.Tests.cs273
-rw-r--r--src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs270
-rw-r--r--src/DevHive.code-workspace3
24 files changed, 553 insertions, 330 deletions
diff --git a/src/DevHive.Data/Interfaces/ILanguageRepository.cs b/src/DevHive.Data/Interfaces/ILanguageRepository.cs
new file mode 100644
index 0000000..40dd461
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/ILanguageRepository.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Data.Models;
+using DevHive.Data.Repositories.Interfaces;
+
+namespace DevHive.Data.Interfaces
+{
+ public interface ILanguageRepository : IRepository<Language>
+ {
+ Task<bool> DoesLanguageExistAsync(Guid id);
+ Task<bool> DoesLanguageNameExistAsync(string languageName);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Data/Interfaces/IPostRepository.cs b/src/DevHive.Data/Interfaces/IPostRepository.cs
new file mode 100644
index 0000000..9c75ecc
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/IPostRepository.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Data.Models;
+using DevHive.Data.Repositories.Interfaces;
+
+namespace DevHive.Data.Interfaces
+{
+ public interface IPostRepository : IRepository<Post>
+ {
+ Task<bool> AddCommentAsync(Comment entity);
+
+ Task<Comment> GetCommentByIdAsync(Guid id);
+
+ Task<bool> EditCommentAsync(Comment newEntity);
+
+ Task<bool> DeleteCommentAsync(Comment entity);
+ Task<bool> DoesCommentExist(Guid id);
+ Task<bool> DoesPostExist(Guid postId);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Data/Repositories/IRepository.cs b/src/DevHive.Data/Interfaces/IRepository.cs
index 920ba13..40a78de 100644
--- a/src/DevHive.Data/Repositories/IRepository.cs
+++ b/src/DevHive.Data/Interfaces/IRepository.cs
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
-namespace DevHive.Data.Repositories
+namespace DevHive.Data.Repositories.Interfaces
{
public interface IRepository<TEntity>
where TEntity : class
diff --git a/src/DevHive.Data/Interfaces/IRoleRepository.cs b/src/DevHive.Data/Interfaces/IRoleRepository.cs
new file mode 100644
index 0000000..48761db
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/IRoleRepository.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Data.Models;
+using DevHive.Data.Repositories.Interfaces;
+
+namespace DevHive.Data.Interfaces
+{
+ public interface IRoleRepository : IRepository<Role>
+ {
+ Task<Role> GetByNameAsync(string name);
+
+ Task<bool> DoesNameExist(string name);
+ Task<bool> DoesRoleExist(Guid id);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Data/Interfaces/ITechnologyRepository.cs b/src/DevHive.Data/Interfaces/ITechnologyRepository.cs
new file mode 100644
index 0000000..7c126a4
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/ITechnologyRepository.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Data.Models;
+using DevHive.Data.Repositories.Interfaces;
+
+namespace DevHive.Data.Interfaces
+{
+ public interface ITechnologyRepository : IRepository<Technology>
+ {
+ Task<bool> DoesTechnologyExistAsync(Guid id);
+ Task<bool> DoesTechnologyNameExist(string technologyName);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Data/Interfaces/IUserRepository.cs b/src/DevHive.Data/Interfaces/IUserRepository.cs
new file mode 100644
index 0000000..8ee5054
--- /dev/null
+++ b/src/DevHive.Data/Interfaces/IUserRepository.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using DevHive.Data.Models;
+using DevHive.Data.Repositories.Interfaces;
+
+namespace DevHive.Data.Interfaces
+{
+ public interface IUserRepository : IRepository<User>
+ {
+ Task<bool> AddFriendAsync(User user, User friend);
+ Task<bool> AddLanguageToUserAsync(User user, Language language);
+ Task<bool> AddTechnologyToUserAsync(User user, Technology technology);
+
+ Task<User> GetByUsername(string username);
+ Language GetUserLanguage(User user, Language language);
+ IList<Language> GetUserLanguages(User user);
+ IList<Technology> GetUserTechnologies(User user);
+ Technology GetUserTechnology(User user, Technology technology);
+ IEnumerable<User> QueryAll();
+
+ Task<bool> EditUserLanguage(User user, Language oldLang, Language newLang);
+ Task<bool> EditUserTechnologies(User user, Technology oldTech, Technology newTech);
+
+ Task<bool> RemoveFriendAsync(User user, User friend);
+ Task<bool> RemoveLanguageFromUserAsync(User user, Language language);
+ Task<bool> RemoveTechnologyFromUserAsync(User user, Technology technology);
+
+ bool DoesUserHaveThisLanguage(User user, Language language);
+ bool DoesUserHaveThisUsername(Guid id, string username);
+ bool DoesUserHaveFriends(User user);
+ Task<bool> DoesEmailExistAsync(string email);
+ Task<bool> DoesUserExistAsync(Guid id);
+ Task<bool> DoesUserHaveThisFriendAsync(Guid userId, Guid friendId);
+ Task<bool> DoesUsernameExistAsync(string username);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Data/Repositories/LanguageRepository.cs b/src/DevHive.Data/Repositories/LanguageRepository.cs
index 5d8217a..c30d3bb 100644
--- a/src/DevHive.Data/Repositories/LanguageRepository.cs
+++ b/src/DevHive.Data/Repositories/LanguageRepository.cs
@@ -1,13 +1,13 @@
using System;
-using System.Linq;
using System.Threading.Tasks;
using DevHive.Common.Models.Misc;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class LanguageRepository : IRepository<Language>
+ public class LanguageRepository : ILanguageRepository
{
private readonly DevHiveContext _context;
diff --git a/src/DevHive.Data/Repositories/PostRepository.cs b/src/DevHive.Data/Repositories/PostRepository.cs
index 002fb17..f5e9b7b 100644
--- a/src/DevHive.Data/Repositories/PostRepository.cs
+++ b/src/DevHive.Data/Repositories/PostRepository.cs
@@ -1,12 +1,13 @@
using System;
using System.Threading.Tasks;
using DevHive.Common.Models.Misc;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class PostRepository : IRepository<Post>
+ public class PostRepository : IPostRepository
{
private readonly DevHiveContext _context;
@@ -52,9 +53,9 @@ namespace DevHive.Data.Repositories
//Update
public async Task<bool> EditAsync(Post newPost)
{
- this._context
- .Set<Post>()
- .Update(newPost);
+ this._context
+ .Set<Post>()
+ .Update(newPost);
return await RepositoryMethods.SaveChangesAsync(this._context);
}
@@ -77,7 +78,7 @@ namespace DevHive.Data.Repositories
return await RepositoryMethods.SaveChangesAsync(this._context);
}
-
+
public async Task<bool> DeleteCommentAsync(Comment entity)
{
this._context
@@ -86,7 +87,7 @@ namespace DevHive.Data.Repositories
return await RepositoryMethods.SaveChangesAsync(this._context);
}
-
+
#region Validations
public async Task<bool> DoesPostExist(Guid postId)
diff --git a/src/DevHive.Data/Repositories/RoleRepository.cs b/src/DevHive.Data/Repositories/RoleRepository.cs
index 0ca1646..4cd5b79 100644
--- a/src/DevHive.Data/Repositories/RoleRepository.cs
+++ b/src/DevHive.Data/Repositories/RoleRepository.cs
@@ -1,12 +1,13 @@
using System;
using System.Threading.Tasks;
using DevHive.Common.Models.Misc;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class RoleRepository : IRepository<Role>
+ public class RoleRepository : IRoleRepository
{
private readonly DevHiveContext _context;
@@ -52,7 +53,7 @@ namespace DevHive.Data.Repositories
return await RepositoryMethods.SaveChangesAsync(this._context);
}
-
+
//Delete
public async Task<bool> DeleteAsync(Role entity)
{
diff --git a/src/DevHive.Data/Repositories/TechnologyRepository.cs b/src/DevHive.Data/Repositories/TechnologyRepository.cs
index 21d69a3..a8208b6 100644
--- a/src/DevHive.Data/Repositories/TechnologyRepository.cs
+++ b/src/DevHive.Data/Repositories/TechnologyRepository.cs
@@ -1,13 +1,14 @@
using System;
using System.Threading.Tasks;
using DevHive.Common.Models.Misc;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class TechnologyRepository : IRepository<Technology>
+ public class TechnologyRepository : ITechnologyRepository
{
private readonly DevHiveContext _context;
@@ -42,9 +43,9 @@ namespace DevHive.Data.Repositories
public async Task<bool> EditAsync(Technology newEntity)
{
- this._context
- .Set<Technology>()
- .Update(newEntity);
+ this._context
+ .Set<Technology>()
+ .Update(newEntity);
return await RepositoryMethods.SaveChangesAsync(this._context);
}
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs
index 64a81ae..1f29bb5 100644
--- a/src/DevHive.Data/Repositories/UserRepository.cs
+++ b/src/DevHive.Data/Repositories/UserRepository.cs
@@ -3,12 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DevHive.Common.Models.Misc;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class UserRepository : IRepository<User>
+ public class UserRepository : IUserRepository
{
private readonly DevHiveContext _context;
@@ -91,7 +92,7 @@ namespace DevHive.Data.Repositories
return user.Langauges
.FirstOrDefault(x => x.Id == language.Id);
}
-
+
public IList<Technology> GetUserTechnologies(User user)
{
return user.Technologies;
@@ -220,7 +221,7 @@ namespace DevHive.Data.Repositories
{
return user.Friends.Count >= 1;
}
-
+
public bool DoesUserHaveThisLanguage(User user, Language language)
{
return user.Langauges.Contains(language);
diff --git a/src/DevHive.Services/Interfaces/ILanguageService.cs b/src/DevHive.Services/Interfaces/ILanguageService.cs
new file mode 100644
index 0000000..f62bce7
--- /dev/null
+++ b/src/DevHive.Services/Interfaces/ILanguageService.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Services.Models.Language;
+
+namespace DevHive.Services.Interfaces
+{
+ public interface ILanguageService
+ {
+ Task<bool> CreateLanguage(CreateLanguageServiceModel createLanguageServiceModel);
+
+ Task<LanguageServiceModel> GetLanguageById(Guid id);
+
+ Task<bool> UpdateLanguage(UpdateLanguageServiceModel languageServiceModel);
+
+ Task<bool> DeleteLanguage(Guid id);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Services/Interfaces/IPostService.cs b/src/DevHive.Services/Interfaces/IPostService.cs
new file mode 100644
index 0000000..9cb21ed
--- /dev/null
+++ b/src/DevHive.Services/Interfaces/IPostService.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Services.Models.Post.Comment;
+using DevHive.Services.Models.Post.Post;
+
+namespace DevHive.Services.Interfaces
+{
+ public interface IPostService
+ {
+ Task<bool> CreatePost(CreatePostServiceModel postServiceModel);
+ Task<bool> AddComment(CreateCommentServiceModel commentServiceModel);
+
+ Task<CommentServiceModel> GetCommentById(Guid id);
+ Task<PostServiceModel> GetPostById(Guid id);
+
+ Task<bool> UpdateComment(UpdateCommentServiceModel commentServiceModel);
+ Task<bool> UpdatePost(UpdatePostServiceModel postServiceModel);
+
+ Task<bool> DeleteComment(Guid id);
+ Task<bool> DeletePost(Guid id);
+
+ Task<bool> ValidateJwtForComment(Guid commentId, string rawTokenData);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Services/Interfaces/IRoleService.cs b/src/DevHive.Services/Interfaces/IRoleService.cs
new file mode 100644
index 0000000..3bf236c
--- /dev/null
+++ b/src/DevHive.Services/Interfaces/IRoleService.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Common.Models.Identity;
+
+namespace DevHive.Services.Interfaces
+{
+ public interface IRoleService
+ {
+ Task<bool> CreateRole(RoleModel roleServiceModel);
+
+ Task<RoleModel> GetRoleById(Guid id);
+
+ Task<bool> UpdateRole(RoleModel roleServiceModel);
+
+ Task<bool> DeleteRole(Guid id);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Services/Interfaces/ITechnologyService.cs b/src/DevHive.Services/Interfaces/ITechnologyService.cs
new file mode 100644
index 0000000..33032e2
--- /dev/null
+++ b/src/DevHive.Services/Interfaces/ITechnologyService.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Services.Models.Technology;
+
+namespace DevHive.Services.Interfaces
+{
+ public interface ITechnologyService
+ {
+ Task<bool> Create(CreateTechnologyServiceModel technologyServiceModel);
+
+ Task<TechnologyServiceModel> GetTechnologyById(Guid id);
+
+ Task<bool> UpdateTechnology(UpdateTechnologyServiceModel updateTechnologyServiceModel);
+
+ Task<bool> DeleteTechnology(Guid id);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Services/Interfaces/IUserService.cs b/src/DevHive.Services/Interfaces/IUserService.cs
new file mode 100644
index 0000000..ba53563
--- /dev/null
+++ b/src/DevHive.Services/Interfaces/IUserService.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Threading.Tasks;
+using DevHive.Common.Models.Identity;
+using DevHive.Services.Models.Identity.User;
+using DevHive.Services.Models.Language;
+using DevHive.Services.Models.Technology;
+
+namespace DevHive.Services.Interfaces
+{
+ public interface IUserService
+ {
+ Task<TokenModel> LoginUser(LoginServiceModel loginModel);
+ Task<TokenModel> RegisterUser(RegisterServiceModel registerModel);
+
+ Task<bool> AddFriend(Guid userId, Guid friendId);
+ Task<bool> AddLanguageToUser(Guid userId, LanguageServiceModel languageServiceModel);
+ Task<bool> AddTechnologyToUser(Guid userId, TechnologyServiceModel technologyServiceModel);
+
+ Task<UserServiceModel> GetFriendById(Guid friendId);
+ Task<UserServiceModel> GetUserById(Guid id);
+
+ Task<UserServiceModel> UpdateUser(UpdateUserServiceModel updateModel);
+
+ Task DeleteUser(Guid id);
+ Task<bool> RemoveFriend(Guid userId, Guid friendId);
+ Task<bool> RemoveLanguageFromUser(Guid userId, LanguageServiceModel languageServiceModel);
+ Task<bool> RemoveTechnologyFromUser(Guid userId, TechnologyServiceModel technologyServiceModel);
+
+ Task<bool> ValidJWT(Guid id, string rawTokenData);
+ }
+} \ No newline at end of file
diff --git a/src/DevHive.Services/Services/LanguageService.cs b/src/DevHive.Services/Services/LanguageService.cs
index ccc64fd..ac7652b 100644
--- a/src/DevHive.Services/Services/LanguageService.cs
+++ b/src/DevHive.Services/Services/LanguageService.cs
@@ -1,34 +1,39 @@
using System;
using System.Threading.Tasks;
using AutoMapper;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
-using DevHive.Data.Repositories;
+using DevHive.Services.Interfaces;
using DevHive.Services.Models.Language;
namespace DevHive.Services.Services
{
- public class LanguageService
+ public class LanguageService : ILanguageService
{
- private readonly LanguageRepository _languageRepository;
+ private readonly ILanguageRepository _languageRepository;
private readonly IMapper _languageMapper;
- public LanguageService(LanguageRepository languageRepository, IMapper mapper)
+ public LanguageService(ILanguageRepository languageRepository, IMapper mapper)
{
this._languageRepository = languageRepository;
this._languageMapper = mapper;
}
+ #region Create
+
public async Task<bool> CreateLanguage(CreateLanguageServiceModel createLanguageServiceModel)
{
if (await this._languageRepository.DoesLanguageNameExistAsync(createLanguageServiceModel.Name))
throw new ArgumentException("Language already exists!");
- //TODO: Fix, cuz it breaks
Language language = this._languageMapper.Map<Language>(createLanguageServiceModel);
bool result = await this._languageRepository.AddAsync(language);
return result;
}
+ #endregion
+
+ #region Read
public async Task<LanguageServiceModel> GetLanguageById(Guid id)
{
@@ -39,6 +44,9 @@ namespace DevHive.Services.Services
return this._languageMapper.Map<LanguageServiceModel>(language);
}
+ #endregion
+
+ #region Update
public async Task<bool> UpdateLanguage(UpdateLanguageServiceModel languageServiceModel)
{
@@ -56,6 +64,9 @@ namespace DevHive.Services.Services
Language lang = this._languageMapper.Map<Language>(languageServiceModel);
return await this._languageRepository.EditAsync(lang);
}
+ #endregion
+
+ #region Delete
public async Task<bool> DeleteLanguage(Guid id)
{
@@ -65,5 +76,6 @@ namespace DevHive.Services.Services
Language language = await this._languageRepository.GetByIdAsync(id);
return await this._languageRepository.DeleteAsync(language);
}
+ #endregion
}
} \ No newline at end of file
diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs
index 321c694..da9e76b 100644
--- a/src/DevHive.Services/Services/PostService.cs
+++ b/src/DevHive.Services/Services/PostService.cs
@@ -7,17 +7,18 @@ using DevHive.Services.Models.Post.Comment;
using DevHive.Services.Models.Post.Post;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
-using DevHive.Data.Repositories;
+using DevHive.Services.Interfaces;
+using DevHive.Data.Interfaces;
namespace DevHive.Services.Services
{
- public class PostService
+ public class PostService : IPostService
{
- private readonly PostRepository _postRepository;
- private readonly UserRepository _userRepository;
+ private readonly IPostRepository _postRepository;
+ private readonly IUserRepository _userRepository;
private readonly IMapper _postMapper;
- public PostService(PostRepository postRepository, UserRepository userRepository , IMapper postMapper)
+ public PostService(IPostRepository postRepository, IUserRepository userRepository, IMapper postMapper)
{
this._postRepository = postRepository;
this._userRepository = userRepository;
@@ -36,16 +37,16 @@ namespace DevHive.Services.Services
{
commentServiceModel.TimeCreated = DateTime.Now;
Comment comment = this._postMapper.Map<Comment>(commentServiceModel);
-
+
bool result = await this._postRepository.AddCommentAsync(comment);
return result;
}
-
+
//Read
public async Task<PostServiceModel> GetPostById(Guid id)
{
- Post post = await this._postRepository.GetByIdAsync(id)
+ Post post = await this._postRepository.GetByIdAsync(id)
?? throw new ArgumentException("Post does not exist!");
return this._postMapper.Map<PostServiceModel>(post);
@@ -55,7 +56,7 @@ namespace DevHive.Services.Services
{
Comment comment = await this._postRepository.GetCommentByIdAsync(id);
- if(comment == null)
+ if (comment == null)
throw new ArgumentException("The comment does not exist");
return this._postMapper.Map<CommentServiceModel>(comment);
@@ -88,7 +89,7 @@ namespace DevHive.Services.Services
Post post = await this._postRepository.GetByIdAsync(id);
return await this._postRepository.DeleteAsync(post);
}
-
+
public async Task<bool> DeleteComment(Guid id)
{
if (!await this._postRepository.DoesCommentExist(id))
@@ -118,7 +119,7 @@ namespace DevHive.Services.Services
string jwtUserName = this.GetClaimTypeValues("unique_name", jwt.Claims)[0];
//List<string> jwtRoleNames = this.GetClaimTypeValues("role", jwt.Claims);
-
+
User user = await this._userRepository.GetByUsername(jwtUserName)
?? throw new ArgumentException("User does not exist!");
@@ -128,8 +129,8 @@ namespace DevHive.Services.Services
private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims)
{
List<string> toReturn = new();
-
- foreach(var claim in claims)
+
+ foreach (var claim in claims)
if (claim.Type == type)
toReturn.Add(claim.Value);
diff --git a/src/DevHive.Services/Services/RoleService.cs b/src/DevHive.Services/Services/RoleService.cs
index 7ba0a98..fd56c2c 100644
--- a/src/DevHive.Services/Services/RoleService.cs
+++ b/src/DevHive.Services/Services/RoleService.cs
@@ -2,17 +2,18 @@ using System;
using System.Threading.Tasks;
using AutoMapper;
using DevHive.Common.Models.Identity;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
-using DevHive.Data.Repositories;
+using DevHive.Services.Interfaces;
namespace DevHive.Services.Services
{
- public class RoleService
+ public class RoleService : IRoleService
{
- private readonly RoleRepository _roleRepository;
+ private readonly IRoleRepository _roleRepository;
private readonly IMapper _roleMapper;
- public RoleService(RoleRepository roleRepository, IMapper mapper)
+ public RoleService(IRoleRepository roleRepository, IMapper mapper)
{
this._roleRepository = roleRepository;
this._roleMapper = mapper;
@@ -30,7 +31,7 @@ namespace DevHive.Services.Services
public async Task<RoleModel> GetRoleById(Guid id)
{
- Role role = await this._roleRepository.GetByIdAsync(id)
+ Role role = await this._roleRepository.GetByIdAsync(id)
?? throw new ArgumentException("Role does not exist!");
return this._roleMapper.Map<RoleModel>(role);
diff --git a/src/DevHive.Services/Services/TechnologyService.cs b/src/DevHive.Services/Services/TechnologyService.cs
index 883b8c5..cb8fdfc 100644
--- a/src/DevHive.Services/Services/TechnologyService.cs
+++ b/src/DevHive.Services/Services/TechnologyService.cs
@@ -1,18 +1,19 @@
using System;
using System.Threading.Tasks;
using AutoMapper;
+using DevHive.Data.Interfaces;
using DevHive.Data.Models;
-using DevHive.Data.Repositories;
+using DevHive.Services.Interfaces;
using DevHive.Services.Models.Technology;
namespace DevHive.Services.Services
{
- public class TechnologyService
+ public class TechnologyService : ITechnologyService
{
- private readonly TechnologyRepository _technologyRepository;
+ private readonly ITechnologyRepository _technologyRepository;
private readonly IMapper _technologyMapper;
- public TechnologyService(TechnologyRepository technologyRepository, IMapper technologyMapper)
+ public TechnologyService(ITechnologyRepository technologyRepository, IMapper technologyMapper)
{
this._technologyRepository = technologyRepository;
this._technologyMapper = technologyMapper;
@@ -38,7 +39,7 @@ namespace DevHive.Services.Services
{
Technology technology = await this._technologyRepository.GetByIdAsync(id);
- if(technology == null)
+ if (technology == null)
throw new ArgumentException("The technology does not exist");
return this._technologyMapper.Map<TechnologyServiceModel>(technology);
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index c1de741..6a6662d 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -12,24 +12,26 @@ using System.Text;
using System.Collections.Generic;
using DevHive.Common.Models.Identity;
using DevHive.Services.Models.Language;
-using DevHive.Data.Repositories;
+using DevHive.Services.Interfaces;
using DevHive.Services.Models.Technology;
+using DevHive.Data.Repositories;
+using DevHive.Data.Interfaces;
namespace DevHive.Services.Services
{
- public class UserService
+ public class UserService : IUserService
{
- private readonly UserRepository _userRepository;
- private readonly RoleRepository _roleRepository;
- private readonly LanguageRepository _languageRepository;
- private readonly TechnologyRepository _technologyRepository;
+ private readonly IUserRepository _userRepository;
+ private readonly IRoleRepository _roleRepository;
+ private readonly ILanguageRepository _languageRepository;
+ private readonly ITechnologyRepository _technologyRepository;
private readonly IMapper _userMapper;
private readonly JWTOptions _jwtOptions;
- public UserService(UserRepository userRepository,
- LanguageRepository languageRepository,
- RoleRepository roleRepository,
- TechnologyRepository technologyRepository,
+ public UserService(IUserRepository userRepository,
+ ILanguageRepository languageRepository,
+ IRoleRepository roleRepository,
+ ITechnologyRepository technologyRepository,
IMapper mapper,
JWTOptions jwtOptions)
{
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyService.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyService.Tests.cs
deleted file mode 100644
index acb5e64..0000000
--- a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyService.Tests.cs
+++ /dev/null
@@ -1,273 +0,0 @@
-using AutoMapper;
-using DevHive.Data;
-using DevHive.Data.Models;
-using DevHive.Data.Repositories;
-using DevHive.Data.Repositories.Contracts;
-using DevHive.Services.Models.Technology;
-using DevHive.Services.Services;
-using Microsoft.EntityFrameworkCore;
-using Moq;
-using NUnit.Framework;
-using System;
-using System.Threading.Tasks;
-
-namespace DevHive.Services.Tests
-{
- [TestFixture]
- public class TechnologyServiceTests
- {
- protected Mock<ITechnologyRepository> TechnologyRepositoryMock { get; set; }
- protected Mock<IMapper> MapperMock { get; set; }
- protected TechnologyService TechnologyService { get; set; }
-
- [SetUp]
- public void Setup()
- {
- this.TechnologyRepositoryMock = new Mock<ITechnologyRepository>();
- this.MapperMock = new Mock<IMapper>();
- this.TechnologyService = new TechnologyService(this.TechnologyRepositoryMock.Object, this.MapperMock.Object);
- }
-
- #region Create
- [Test]
- [TestCase(true)]
- [TestCase(false)]
- public void Create_ReturnsTrue_WhenEntityIsAddedSuccessfully(bool shouldFail)
- {
- Task.Run(async () =>
- {
- string technologyName = "Gosho Trapov";
-
- TechnologyServiceModel technologyServiceModel = new TechnologyServiceModel
- {
- Name = technologyName
- };
- Technology technology = new Technology
- {
- Name = technologyName
- };
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(false));
- this.TechnologyRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Technology>())).Returns(Task.FromResult(shouldFail));
- this.MapperMock.Setup(p => p.Map<Technology>(It.IsAny<TechnologyServiceModel>())).Returns(technology);
-
- bool result = await this.TechnologyService.Create(technologyServiceModel);
-
- Assert.AreEqual(shouldFail, result);
- }).GetAwaiter().GetResult();
- }
-
- [Test]
- public void Create_ThrowsArgumentException_WhenEntityAlreadyExists()
- {
- Task.Run(async () =>
- {
- string expectedExceptionMessage = "Technology already exists!";
- string technologyName = "Gosho Trapov";
-
- TechnologyServiceModel technologyServiceModel = new TechnologyServiceModel
- {
- Name = technologyName
- };
- Technology technology = new Technology
- {
- Name = technologyName
- };
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(true));
-
- try
- {
- await this.TechnologyService.Create(technologyServiceModel);
- Assert.Fail("Create does not throw exception when technology already exists");
- }
- catch(ArgumentException ex)
- {
- Assert.AreEqual(expectedExceptionMessage, ex.Message);
- }
- }).GetAwaiter().GetResult();
- }
- #endregion
-
- #region GetById
- [Test]
- public void GetTechnologyById_ReturnsTheTechnology_WhenItExists()
- {
- Task.Run(async () =>
- {
- Guid id = new Guid();
- string name = "Gosho Trapov";
- Technology technology = new Technology
- {
- Name = name
- };
- TechnologyServiceModel technologyServiceModel = new TechnologyServiceModel
- {
- Name = name
- };
-
- this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(technology));
- this.MapperMock.Setup(p => p.Map<TechnologyServiceModel>(It.IsAny<Technology>())).Returns(technologyServiceModel);
-
- TechnologyServiceModel result = await this.TechnologyService.GetTechnologyById(id);
-
- Assert.AreEqual(name, result.Name);
- }).GetAwaiter().GetResult();
- }
-
- [Test]
- public void GetTechnologyById_ThrowsException_WhenTechnologyDoesNotExist()
- {
- Task.Run(async () =>
- {
- string exceptionMessage = "The technology does not exist";
- Guid id = new Guid();
- this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult<Technology>(null));
-
- try
- {
- await this.TechnologyService.GetTechnologyById(id);
- Assert.Fail("GetTechnologyById does not throw exception when technology does not exist");
- }
- catch(ArgumentException ex)
- {
- Assert.AreEqual(exceptionMessage, ex.Message, "Exception messege is nto correct");
- }
- }).GetAwaiter().GetResult();
- }
- #endregion
-
- #region Update
- [Test]
- [TestCase(true)]
- [TestCase(false)]
- public void UpdateTechnology_ReturnsIfUpdateIsSuccessfull_WhenTechnologyExistsy(bool shouldPass)
- {
- Task.Run(async () =>
- {
- Guid id = new Guid();
- string name = "Gosho Trapov";
- Technology technology = new Technology
- {
- Name = name
- };
- UpdateTechnologyServiceModel updatetechnologyServiceModel = new UpdateTechnologyServiceModel
- {
- Name = name,
- Id = id
- };
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(false));
- this.TechnologyRepositoryMock.Setup(p => p.EditAsync(It.IsAny<Technology>())).Returns(Task.FromResult(shouldPass));
- this.MapperMock.Setup(p => p.Map<Technology>(It.IsAny<UpdateTechnologyServiceModel>())).Returns(technology);
-
- bool result = await this.TechnologyService.UpdateTechnology(updatetechnologyServiceModel);
-
- Assert.AreEqual(shouldPass, result);
- }).GetAwaiter().GetResult();
- }
-
- [Test]
- public void UpdateTechnology_ThrowsException_WhenTechnologyDoesNotExist()
- {
- Task.Run(async () =>
- {
- string exceptionMessage = "Technology does not exist!";
- Guid id = new Guid();
- UpdateTechnologyServiceModel updateTechnologyServiceModel = new UpdateTechnologyServiceModel
- {
- Id = id
- };
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(false));
-
- try
- {
- await this.TechnologyService.UpdateTechnology(updateTechnologyServiceModel);
- Assert.Fail("UpdateTechnology does not throw exception when technology does not exist");
- }
- catch(ArgumentException ex)
- {
- Assert.AreEqual(exceptionMessage, ex.Message, "Exception Message is not correct");
- }
- }).GetAwaiter().GetResult();
- }
-
- [Test]
- public void UpdateTechnology_ThrowsException_WhenTechnologyNameAlreadyExists()
- {
- Task.Run(async () =>
- {
- string exceptionMessage = "Technology name already exists!";
- Guid id = new Guid();
- UpdateTechnologyServiceModel updateTechnologyServiceModel = new UpdateTechnologyServiceModel
- {
- Id = id
- };
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(true));
-
- try
- {
- await this.TechnologyService.UpdateTechnology(updateTechnologyServiceModel);
- Assert.Fail("UpdateTechnology does not throw exception when technology name already exist");
- }
- catch(ArgumentException ex)
- {
- Assert.AreEqual(exceptionMessage, ex.Message, "Exception Message is not correct");
- }
- }).GetAwaiter().GetResult();
- }
- #endregion
-
- #region Delete
- [Test]
- [TestCase(true)]
- [TestCase(false)]
- public void DeleteTechnology_ShouldReturnIfDeletionIsSuccessfull_WhenTechnologyExists(bool shouldPass)
- {
- Task.Run(async () =>
- {
- Guid id = new Guid();
- Technology technology = new Technology();
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(true));
- this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(technology));
- this.TechnologyRepositoryMock.Setup(p => p.DeleteAsync(It.IsAny<Technology>())).Returns(Task.FromResult(shouldPass));
-
- bool result = await this.TechnologyService.DeleteTechnology(id);
-
- Assert.AreEqual(shouldPass, result);
- }).GetAwaiter().GetResult();
- }
-
- [Test]
- public void DeleteTechnology_ThrowsException_WhenTechnologyDoesNotExist()
- {
- Task.Run(async () =>
- {
- string exceptionMessage = "Technology does not exist!";
- Guid id = new Guid();
-
- this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(false));
-
- try
- {
- await this.TechnologyService.DeleteTechnology(id);
- Assert.Fail("DeleteTechnology does not throw exception when technology does not exist");
- }
- catch(ArgumentException ex)
- {
- Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
- }
- }).GetAwaiter().GetResult();
- }
- #endregion
- //Task.Run(async () =>
- //{
- //
- //}).GetAwaiter().GetResult();
- }
-}
diff --git a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs
new file mode 100644
index 0000000..f335aba
--- /dev/null
+++ b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs
@@ -0,0 +1,270 @@
+using AutoMapper;
+using DevHive.Data.Interfaces;
+using DevHive.Data.Models;
+using DevHive.Services.Models.Technology;
+using DevHive.Services.Services;
+using Moq;
+using NUnit.Framework;
+using System;
+using System.Threading.Tasks;
+
+namespace DevHive.Services.Tests
+{
+ [TestFixture]
+ public class TechnologyServicesTests
+ {
+ private Mock<ITechnologyRepository> TechnologyRepositoryMock { get; set; }
+ private Mock<IMapper> MapperMock { get; set; }
+ private TechnologyService TechnologyService { get; set; }
+
+ [SetUp]
+ public void Setup()
+ {
+ this.TechnologyRepositoryMock = new Mock<ITechnologyRepository>();
+ this.MapperMock = new Mock<IMapper>();
+ this.TechnologyService = new TechnologyService(this.TechnologyRepositoryMock.Object, this.MapperMock.Object);
+ }
+
+ #region Create
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Create_ReturnsTrue_WhenEntityIsAddedSuccessfully(bool shouldFail)
+ {
+ Task.Run(async () =>
+ {
+ string technologyName = "Gosho Trapov";
+
+ CreateTechnologyServiceModel createTechnologyServiceModel = new()
+ {
+ Name = technologyName
+ };
+ Technology technology = new()
+ {
+ Name = technologyName
+ };
+
+ this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(false));
+ this.TechnologyRepositoryMock.Setup(p => p.AddAsync(It.IsAny<Technology>())).Returns(Task.FromResult(shouldFail));
+ this.MapperMock.Setup(p => p.Map<Technology>(It.IsAny<CreateTechnologyServiceModel>())).Returns(technology);
+
+ bool result = await this.TechnologyService.Create(createTechnologyServiceModel);
+
+ Assert.AreEqual(shouldFail, result);
+ }).GetAwaiter().GetResult();
+ }
+
+ [Test]
+ public void Create_ThrowsArgumentException_WhenEntityAlreadyExists()
+ {
+ Task.Run(async () =>
+ {
+ string expectedExceptionMessage = "Technology already exists!";
+ string technologyName = "Gosho Trapov";
+
+ CreateTechnologyServiceModel createTechnologyServiceModel = new()
+ {
+ Name = technologyName
+ };
+ Technology technology = new()
+ {
+ Name = technologyName
+ };
+
+ this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ try
+ {
+ await this.TechnologyService.Create(createTechnologyServiceModel);
+ Assert.Fail("Create does not throw exception when technology already exists");
+ }
+ catch (ArgumentException ex)
+ {
+ Assert.AreEqual(expectedExceptionMessage, ex.Message);
+ }
+ }).GetAwaiter().GetResult();
+ }
+ #endregion
+
+ // #region GetById
+ // [Test]
+ // public void GetTechnologyById_ReturnsTheTechnology_WhenItExists()
+ // {
+ // Task.Run(async () =>
+ // {
+ // Guid id = new Guid();
+ // string name = "Gosho Trapov";
+ // Technology technology = new()
+ // {
+ // Name = name
+ // };
+ // TechnologyServiceModel technologyServiceModel = new())
+ // {
+ // Name = name
+ // };
+
+ // this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(technology));
+ // this.MapperMock.Setup(p => p.Map<TechnologyServiceModel>(It.IsAny<Technology>())).Returns(technologyServiceModel);
+
+ // TechnologyServiceModel result = await this.TechnologyService.GetTechnologyById(id);
+
+ // Assert.AreEqual(name, result.Name);
+ // }).GetAwaiter().GetResult();
+ // }
+
+ // [Test]
+ // public void GetTechnologyById_ThrowsException_WhenTechnologyDoesNotExist()
+ // {
+ // Task.Run(async () =>
+ // {
+ // string exceptionMessage = "The technology does not exist";
+ // Guid id = new Guid();
+ // this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult<Technology>(null));
+
+ // try
+ // {
+ // await this.TechnologyService.GetTechnologyById(id);
+ // Assert.Fail("GetTechnologyById does not throw exception when technology does not exist");
+ // }
+ // catch (ArgumentException ex)
+ // {
+ // Assert.AreEqual(exceptionMessage, ex.Message, "Exception messege is nto correct");
+ // }
+ // }).GetAwaiter().GetResult();
+ // }
+ // #endregion
+
+ // #region Update
+ // [Test]
+ // [TestCase(true)]
+ // [TestCase(false)]
+ // public void UpdateTechnology_ReturnsIfUpdateIsSuccessfull_WhenTechnologyExistsy(bool shouldPass)
+ // {
+ // Task.Run(async () =>
+ // {
+ // Guid id = new Guid();
+ // string name = "Gosho Trapov";
+ // Technology technology = new Technology
+ // {
+ // Name = name
+ // };
+ // UpdateTechnologyServiceModel updatetechnologyServiceModel = new UpdateTechnologyServiceModel
+ // {
+ // Name = name,
+ // Id = id
+ // };
+
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(false));
+ // this.TechnologyRepositoryMock.Setup(p => p.EditAsync(It.IsAny<Technology>())).Returns(Task.FromResult(shouldPass));
+ // this.MapperMock.Setup(p => p.Map<Technology>(It.IsAny<UpdateTechnologyServiceModel>())).Returns(technology);
+
+ // bool result = await this.TechnologyService.UpdateTechnology(updatetechnologyServiceModel);
+
+ // Assert.AreEqual(shouldPass, result);
+ // }).GetAwaiter().GetResult();
+ // }
+
+ // [Test]
+ // public void UpdateTechnology_ThrowsException_WhenTechnologyDoesNotExist()
+ // {
+ // Task.Run(async () =>
+ // {
+ // string exceptionMessage = "Technology does not exist!";
+ // Guid id = new Guid();
+ // UpdateTechnologyServiceModel updateTechnologyServiceModel = new UpdateTechnologyServiceModel
+ // {
+ // Id = id
+ // };
+
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+
+ // try
+ // {
+ // await this.TechnologyService.UpdateTechnology(updateTechnologyServiceModel);
+ // Assert.Fail("UpdateTechnology does not throw exception when technology does not exist");
+ // }
+ // catch (ArgumentException ex)
+ // {
+ // Assert.AreEqual(exceptionMessage, ex.Message, "Exception Message is not correct");
+ // }
+ // }).GetAwaiter().GetResult();
+ // }
+
+ // [Test]
+ // public void UpdateTechnology_ThrowsException_WhenTechnologyNameAlreadyExists()
+ // {
+ // Task.Run(async () =>
+ // {
+ // string exceptionMessage = "Technology name already exists!";
+ // Guid id = new Guid();
+ // UpdateTechnologyServiceModel updateTechnologyServiceModel = new UpdateTechnologyServiceModel
+ // {
+ // Id = id
+ // };
+
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExist(It.IsAny<string>())).Returns(Task.FromResult(true));
+
+ // try
+ // {
+ // await this.TechnologyService.UpdateTechnology(updateTechnologyServiceModel);
+ // Assert.Fail("UpdateTechnology does not throw exception when technology name already exist");
+ // }
+ // catch (ArgumentException ex)
+ // {
+ // Assert.AreEqual(exceptionMessage, ex.Message, "Exception Message is not correct");
+ // }
+ // }).GetAwaiter().GetResult();
+ // }
+ // #endregion
+
+ // #region Delete
+ // [Test]
+ // [TestCase(true)]
+ // [TestCase(false)]
+ // public void DeleteTechnology_ShouldReturnIfDeletionIsSuccessfull_WhenTechnologyExists(bool shouldPass)
+ // {
+ // Task.Run(async () =>
+ // {
+ // Guid id = new Guid();
+ // Technology technology = new Technology();
+
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(true));
+ // this.TechnologyRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(technology));
+ // this.TechnologyRepositoryMock.Setup(p => p.DeleteAsync(It.IsAny<Technology>())).Returns(Task.FromResult(shouldPass));
+
+ // bool result = await this.TechnologyService.DeleteTechnology(id);
+
+ // Assert.AreEqual(shouldPass, result);
+ // }).GetAwaiter().GetResult();
+ // }
+
+ // [Test]
+ // public void DeleteTechnology_ThrowsException_WhenTechnologyDoesNotExist()
+ // {
+ // Task.Run(async () =>
+ // {
+ // string exceptionMessage = "Technology does not exist!";
+ // Guid id = new Guid();
+
+ // this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyExistAsync(It.IsAny<Guid>())).Returns(Task.FromResult(false));
+
+ // try
+ // {
+ // await this.TechnologyService.DeleteTechnology(id);
+ // Assert.Fail("DeleteTechnology does not throw exception when technology does not exist");
+ // }
+ // catch (ArgumentException ex)
+ // {
+ // Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message");
+ // }
+ // }).GetAwaiter().GetResult();
+ // }
+ // #endregion
+ // //Task.Run(async () =>
+ // //{
+ // //
+ // //}).GetAwaiter().GetResult();
+ }
+}
diff --git a/src/DevHive.code-workspace b/src/DevHive.code-workspace
index 04a9a2f..675cfea 100644
--- a/src/DevHive.code-workspace
+++ b/src/DevHive.code-workspace
@@ -37,7 +37,8 @@
"e2e" : true,
},
"code-runner.fileDirectoryAsCwd": true,
- "compile-hero.disable-compile-files-on-did-save-code": true
+ "dotnet-test-explorer.runInParallel": true,
+ "dotnet-test-explorer.testProjectPath": "**/*.Tests.csproj",
},
"launch": {
"configurations": [