aboutsummaryrefslogtreecommitdiff
path: root/src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-03-14 11:07:04 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-03-14 11:07:04 +0200
commit039909bd4d1a49773e6261c110cac4495f3a12fb (patch)
treee584a3662fe5dd3d10b9bf4afeff36b38f19c2ad /src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs
parent8adb24d535c54de558cd1278d5e98632bed755e3 (diff)
downloadDevHive-039909bd4d1a49773e6261c110cac4495f3a12fb.tar
DevHive-039909bd4d1a49773e6261c110cac4495f3a12fb.tar.gz
DevHive-039909bd4d1a49773e6261c110cac4495f3a12fb.zip
Made properties into variables, fixed spacing and made protected members private, all in Data layer tests
Diffstat (limited to 'src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs')
-rw-r--r--src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs b/src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs
index f7fbacb..c12a38e 100644
--- a/src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs
+++ b/src/Data/DevHive.Data.Tests/TechnologyRepository.Tests.cs
@@ -12,10 +12,8 @@ namespace DevHive.Data.Tests
public class TechnologyRepositoryTests
{
private const string TECHNOLOGY_NAME = "Technology test name";
-
- protected DevHiveContext Context { get; set; }
-
- protected TechnologyRepository TechnologyRepository { get; set; }
+ private DevHiveContext _context;
+ private TechnologyRepository _technologyRepository;
#region Setups
[SetUp]
@@ -24,15 +22,15 @@ namespace DevHive.Data.Tests
DbContextOptionsBuilder<DevHiveContext> optionsBuilder = new DbContextOptionsBuilder<DevHiveContext>()
.UseInMemoryDatabase(databaseName: "DevHive_Test_Database");
- this.Context = new DevHiveContext(optionsBuilder.Options);
+ this._context = new DevHiveContext(optionsBuilder.Options);
- this.TechnologyRepository = new TechnologyRepository(this.Context);
+ this._technologyRepository = new TechnologyRepository(this._context);
}
[TearDown]
public void TearDown()
{
- _ = this.Context.Database.EnsureDeleted();
+ _ = this._context.Database.EnsureDeleted();
}
#endregion
@@ -42,9 +40,9 @@ namespace DevHive.Data.Tests
{
await this.AddEntity();
- Technology technology = this.Context.Technologies.Where(x => x.Name == TECHNOLOGY_NAME).AsEnumerable().FirstOrDefault();
+ Technology technology = this._context.Technologies.Where(x => x.Name == TECHNOLOGY_NAME).AsEnumerable().FirstOrDefault();
- Technology resultTechnology = await this.TechnologyRepository.GetByNameAsync(TECHNOLOGY_NAME);
+ Technology resultTechnology = await this._technologyRepository.GetByNameAsync(TECHNOLOGY_NAME);
Assert.AreEqual(technology.Id, resultTechnology.Id);
}
@@ -52,7 +50,7 @@ namespace DevHive.Data.Tests
[Test]
public async Task GetByNameAsync_ReturnsNull_IfTechnologyDoesNotExists()
{
- Technology resultTechnology = await this.TechnologyRepository.GetByNameAsync(TECHNOLOGY_NAME);
+ Technology resultTechnology = await this._technologyRepository.GetByNameAsync(TECHNOLOGY_NAME);
Assert.IsNull(resultTechnology);
}
@@ -63,10 +61,10 @@ namespace DevHive.Data.Tests
public async Task DoesTechnologyExist_ReturnsTrue_IfIdExists()
{
await this.AddEntity();
- Technology technology = this.Context.Technologies.Where(x => x.Name == TECHNOLOGY_NAME).AsEnumerable().FirstOrDefault();
+ Technology technology = this._context.Technologies.Where(x => x.Name == TECHNOLOGY_NAME).AsEnumerable().FirstOrDefault();
Guid id = technology.Id;
- bool result = await this.TechnologyRepository.DoesTechnologyExistAsync(id);
+ bool result = await this._technologyRepository.DoesTechnologyExistAsync(id);
Assert.IsTrue(result, "DoesTechnologyExistAsync returns flase hwen technology exists");
}
@@ -76,7 +74,7 @@ namespace DevHive.Data.Tests
{
Guid id = Guid.NewGuid();
- bool result = await this.TechnologyRepository.DoesTechnologyExistAsync(id);
+ bool result = await this._technologyRepository.DoesTechnologyExistAsync(id);
Assert.IsFalse(result, "DoesTechnologyExistAsync returns true when technology does not exist");
}
@@ -88,7 +86,7 @@ namespace DevHive.Data.Tests
{
await this.AddEntity();
- bool result = await this.TechnologyRepository.DoesTechnologyNameExistAsync(TECHNOLOGY_NAME);
+ bool result = await this._technologyRepository.DoesTechnologyNameExistAsync(TECHNOLOGY_NAME);
Assert.IsTrue(result, "DoesTechnologyNameExists returns true when technology name does not exist");
}
@@ -96,7 +94,7 @@ namespace DevHive.Data.Tests
[Test]
public async Task DoesTechnologyNameExist_ReturnsFalse_IfTechnologyDoesNotExists()
{
- bool result = await this.TechnologyRepository.DoesTechnologyNameExistAsync(TECHNOLOGY_NAME);
+ bool result = await this._technologyRepository.DoesTechnologyNameExistAsync(TECHNOLOGY_NAME);
Assert.False(result, "DoesTechnologyNameExistAsync returns true when technology name does not exist");
}
@@ -110,8 +108,8 @@ namespace DevHive.Data.Tests
Name = name
};
- _ = this.Context.Technologies.Add(technology);
- _ = await this.Context.SaveChangesAsync();
+ _ = this._context.Technologies.Add(technology);
+ _ = await this._context.SaveChangesAsync();
}
#endregion
}