aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Tests/DevHive.Data.Tests/TechnologyRepository.Tests.cs
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:51:35 +0300
committerGitHub <noreply@github.com>2021-04-09 19:51:35 +0300
commit233f38915ba0079079233eff55434ef349c05c45 (patch)
tree6c5f69017865bcab87355e910c87339453da1406 /src/DevHive.Tests/DevHive.Data.Tests/TechnologyRepository.Tests.cs
parentf4a70c6430db923af9fa9958a11c2d6612cb52cc (diff)
parenta992357efcf1bc1ece81b95ecee5e05a0b73bfdc (diff)
downloadDevHive-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/TechnologyRepository.Tests.cs')
-rw-r--r--src/DevHive.Tests/DevHive.Data.Tests/TechnologyRepository.Tests.cs118
1 files changed, 0 insertions, 118 deletions
diff --git a/src/DevHive.Tests/DevHive.Data.Tests/TechnologyRepository.Tests.cs b/src/DevHive.Tests/DevHive.Data.Tests/TechnologyRepository.Tests.cs
deleted file mode 100644
index d25fd3b..0000000
--- a/src/DevHive.Tests/DevHive.Data.Tests/TechnologyRepository.Tests.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using DevHive.Data.Models;
-using DevHive.Data.Repositories;
-using Microsoft.EntityFrameworkCore;
-using NUnit.Framework;
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace DevHive.Data.Tests
-{
- [TestFixture]
- public class TechnologyRepositoryTests
- {
- private const string TECHNOLOGY_NAME = "Technology test name";
-
- protected DevHiveContext Context { get; set; }
-
- protected TechnologyRepository TechnologyRepository { get; set; }
-
- #region Setups
- [SetUp]
- public void Setup()
- {
- var optionsBuilder = new DbContextOptionsBuilder<DevHiveContext>()
- .UseInMemoryDatabase(databaseName: "DevHive_Test_Database");
-
- this.Context = new DevHiveContext(optionsBuilder.Options);
-
- TechnologyRepository = new TechnologyRepository(Context);
- }
-
- [TearDown]
- public void TearDown()
- {
- this.Context.Database.EnsureDeleted();
- }
- #endregion
-
- #region GetByNameAsync
- [Test]
- public async Task GetByNameAsync_ReturnsTheCorrectTechnology_IfItExists()
- {
- await AddEntity();
-
- Technology technology = this.Context.Technologies.Where(x => x.Name == TECHNOLOGY_NAME).ToList().FirstOrDefault();
-
- Technology resultTechnology = await this.TechnologyRepository.GetByNameAsync(TECHNOLOGY_NAME);
-
- Assert.AreEqual(technology.Id, resultTechnology.Id);
- }
-
- [Test]
- public async Task GetByNameAsync_ReturnsNull_IfTechnologyDoesNotExists()
- {
- Technology resultTechnology = await this.TechnologyRepository.GetByNameAsync(TECHNOLOGY_NAME);
-
- Assert.IsNull(resultTechnology);
- }
- #endregion
-
- #region DoesTechnologyExistAsync
- [Test]
- public async Task DoesTechnologyExist_ReturnsTrue_IfIdExists()
- {
- await AddEntity();
- Technology technology = this.Context.Technologies.Where(x => x.Name == TECHNOLOGY_NAME).ToList().FirstOrDefault();
- Guid id = technology.Id;
-
- bool result = await this.TechnologyRepository.DoesTechnologyExistAsync(id);
-
- Assert.IsTrue(result, "DoesTechnologyExistAsync returns flase hwen technology exists");
- }
-
- [Test]
- public async Task DoesTechnologyExist_ReturnsFalse_IfIdDoesNotExists()
- {
- Guid id = Guid.NewGuid();
-
- bool result = await this.TechnologyRepository.DoesTechnologyExistAsync(id);
-
- Assert.IsFalse(result, "DoesTechnologyExistAsync returns true when technology does not exist");
- }
- #endregion
-
- #region DoesTechnologyNameExistAsync
- [Test]
- public async Task DoesTechnologyNameExist_ReturnsTrue_IfTechnologyExists()
- {
- await AddEntity();
-
- bool result = await this.TechnologyRepository.DoesTechnologyNameExistAsync(TECHNOLOGY_NAME);
-
- Assert.IsTrue(result, "DoesTechnologyNameExists returns true when technology name does not exist");
- }
-
- [Test]
- public async Task DoesTechnologyNameExist_ReturnsFalse_IfTechnologyDoesNotExists()
- {
- bool result = await this.TechnologyRepository.DoesTechnologyNameExistAsync(TECHNOLOGY_NAME);
-
- Assert.False(result, "DoesTechnologyNameExistAsync returns true when technology name does not exist");
- }
- #endregion
-
- #region HelperMethods
- private async Task AddEntity(string name = TECHNOLOGY_NAME)
- {
- Technology technology = new Technology
- {
- Name = name
- };
-
- this.Context.Technologies.Add(technology);
- await this.Context.SaveChangesAsync();
- }
- #endregion
- }
-}