aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs b/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
index f520426..d171460 100644
--- a/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
+++ b/src/DevHive.Tests/DevHive.Data.Tests/UserRepositoryTests.cs
@@ -12,6 +12,7 @@ namespace DevHive.Data.Tests
[TestFixture]
public class UserRepositoryTests
{
+ private DevHiveContext _context;
private UserRepository _userRepository;
private List<Language> _dummyLanguageList;
@@ -27,8 +28,8 @@ namespace DevHive.Data.Tests
var options = new DbContextOptionsBuilder<DevHiveContext>()
.UseInMemoryDatabase("DevHive_UserRepository_Database");
- var context = new DevHiveContext(options.Options);
- this._userRepository = new UserRepository(context);
+ this._context = new DevHiveContext(options.Options);
+ this._userRepository = new UserRepository(_context);
this._dummyLanguageList = new()
{
@@ -82,6 +83,12 @@ namespace DevHive.Data.Tests
};
}
+ [TearDown]
+ public void Teardown()
+ {
+ this._context.Database.EnsureDeleted();
+ }
+
#region Create
[Test]
public async Task AddAsync_ShouldAddUserToDatabase()
@@ -92,7 +99,7 @@ namespace DevHive.Data.Tests
bool result = await _userRepository.AddAsync(this._dummyUser);
//Assert
- Assert.AreEqual(true, result, "User does not insert into database properly");
+ Assert.True(result, "User does not insert into database properly");
}
[Test]
@@ -106,29 +113,28 @@ namespace DevHive.Data.Tests
bool result = await this._userRepository.AddFriendToUserAsync(this._dummyUser, _dummyUserTwo);
//Assert
- Assert.AreEqual(true, result, "Friend didn't save properly in the database");
- Assert.AreEqual(true, this._dummyUser.Friends.Contains(_dummyUserTwo), "Friend doesn't get added to user properly");
+ Assert.True(result, "Friend didn't save properly in the database");
+ Assert.True(this._dummyUser.Friends.Contains(_dummyUserTwo), "Friend doesn't get added to user properly");
}
[Test]
public async Task AddLanguageToUserAsync_ShouldAddLanguageToUser()
{
//Arrange
+ bool added = await this._userRepository.AddAsync(this._dummyUser);
+ Assert.True(added, "User not inserted properly!");
Language language = new()
{
Id = Guid.NewGuid(),
Name = "typescript"
};
- foreach (var user in this._userRepository.QueryAll())
- Console.WriteLine(user);
-
//Act
bool result = await this._userRepository.AddLanguageToUserAsync(this._dummyUser, language);
//Assert
- Assert.AreEqual(true, result, "The language isn't inserted properly to the database");
- Assert.AreEqual(true, this._dummyUser.Langauges.Contains(language), "The language doesn't get added properly to the user");
+ Assert.True(result, "The language isn't inserted properly to the database");
+ Assert.True(this._dummyUser.Langauges.Contains(language), "The language doesn't get added properly to the user");
}
[Test]
@@ -146,8 +152,8 @@ namespace DevHive.Data.Tests
bool result = await this._userRepository.AddTechnologyToUserAsync(this._dummyUser, technology);
//Assert
- Assert.AreEqual(true, result, "The technology isn't inserted properly to the database");
- Assert.AreEqual(true, this._dummyUser.Technologies.Contains(technology), "The technology doesn't get added properly to the user");
+ Assert.True(result, "The technology isn't inserted properly to the database");
+ Assert.True(this._dummyUser.Technologies.Contains(technology), "The technology doesn't get added properly to the user");
}
#endregion