Docker + Jenkfins File + v0.1
This commit is contained in:
38
UnitTest/DB.cs
Normal file
38
UnitTest/DB.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using GeradoresService;
|
||||
using GeradoresService.DAL;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
public class DB
|
||||
{
|
||||
|
||||
private readonly GeradoresContext _context;
|
||||
public DB()
|
||||
{
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
|
||||
// Obter a connection string a partir do arquivo de configura<72><61>o
|
||||
var connectionString = configuration.GetConnectionString("GeradoresConnection");
|
||||
|
||||
// Configurar o DbContext para usar o InMemoryDatabase
|
||||
var options = new DbContextOptionsBuilder<GeradoresContext>()
|
||||
.UseSqlServer(connectionString)
|
||||
.Options;
|
||||
|
||||
_context = new GeradoresContext(options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateNIF()
|
||||
{
|
||||
var nif = new NIF(_context);
|
||||
var gerenatednif = nif.Generate("2");
|
||||
Assert.NotEmpty(gerenatednif);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user