blob: e4ca614e52af9686bc787e7c2981e9ccc59575b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
using Microsoft.EntityFrameworkCore;
using NUnit.Framework;
using DevHive.Data;
using DevHive.Data.Repositories;
using DevHive.Data.Models;
using System.Threading.Tasks;
using System.Linq;
namespace DevHive.Tests.Data
{
[TestFixture]
public class TechnologyRepositoryTests
{
private const string TECHNOLOGY_NAME = "Technology test name";
protected DevHiveContext Context { get;set; }
protected TechnologyRepository TechnologyRepository { get;set; }
[SetUp]
public void Setup()
{
var optionsBuilder = new DbContextOptionsBuilder<DevHiveContext>()
.UseInMemoryDatabase(databaseName: "DevHive_Test_Database");
this.Context = new DevHiveContext(optionsBuilder.Options);
TechnologyRepository = new TechnologyRepository(Context);
AddEntity();
}
[Test]
public void AddAsync_AddsTheGivenTechnologyToTheDatabase()
{
int numberOfTechnologies = Context.Technologies.Count();
Assert.True(numberOfTechnologies > 0, "Technologies repo does not store Technologies correctly");
}
private void AddEntity()
{
Task.Run(async () =>
{
Technology technology = new Technology
{
Name = TECHNOLOGY_NAME
};
await this.TechnologyRepository.AddAsync(technology);
}).GetAwaiter().GetResult();
}
}
}
|