2025-07-16 00:47:50 +01:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2018-07-15 06:47:41 +02:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Yavsc.Models;
|
|
|
|
|
|
using Xunit.Abstractions;
|
2018-09-07 16:19:30 +02:00
|
|
|
|
using Yavsc.Server.Models.IT.SourceCode;
|
2025-07-13 18:13:04 +01:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2026-06-14 20:05:01 +01:00
|
|
|
|
using yavscTests.ServerFixtures;
|
2026-03-09 02:07:09 +00:00
|
|
|
|
using Yavsc.Server.Models.IT;
|
2018-07-15 06:47:41 +02:00
|
|
|
|
|
2021-06-06 20:32:39 +01:00
|
|
|
|
namespace yavscTests
|
2018-07-15 06:47:41 +02:00
|
|
|
|
{
|
2025-07-16 00:47:50 +01:00
|
|
|
|
[Collection("Yavsc Server")]
|
2021-01-04 00:11:27 +00:00
|
|
|
|
[Trait("regression", "oui")]
|
2025-07-13 18:13:04 +01:00
|
|
|
|
public class BaseTestContext: IClassFixture<WebServerFixture>, IDisposable
|
2018-07-15 06:47:41 +02:00
|
|
|
|
{
|
2025-07-13 18:13:04 +01:00
|
|
|
|
public readonly WebServerFixture _serverFixture;
|
|
|
|
|
|
private readonly ITestOutputHelper _output;
|
2019-01-05 13:28:17 +00:00
|
|
|
|
|
2025-07-13 18:13:04 +01:00
|
|
|
|
public BaseTestContext(ITestOutputHelper output, WebServerFixture fixture)
|
2018-07-15 06:47:41 +02:00
|
|
|
|
{
|
2025-07-13 18:13:04 +01:00
|
|
|
|
this._serverFixture = fixture;
|
|
|
|
|
|
this._output = output;
|
2018-08-01 06:12:42 +02:00
|
|
|
|
}
|
2019-01-05 13:28:17 +00:00
|
|
|
|
|
2026-03-09 02:07:09 +00:00
|
|
|
|
// FIXME write a scenario from an empty database [Fact]
|
2018-07-25 02:12:13 +02:00
|
|
|
|
public void GitClone()
|
2018-07-15 06:47:41 +02:00
|
|
|
|
{
|
2025-07-15 15:42:30 +01:00
|
|
|
|
using var scope = _serverFixture.Services.CreateScope();
|
|
|
|
|
|
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
2026-03-09 02:07:09 +00:00
|
|
|
|
Assert.NotNull(dbContext.Project);
|
|
|
|
|
|
Project yavsc = new Project
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Yavsc"
|
|
|
|
|
|
};
|
|
|
|
|
|
dbContext.Project.Add(yavsc);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
var firstProject = dbContext.Project.Include(p => p.Repository).FirstOrDefault(
|
|
|
|
|
|
p => p.Name == "Yavsc"
|
|
|
|
|
|
);
|
2018-07-25 02:12:13 +02:00
|
|
|
|
Assert.NotNull (firstProject);
|
2025-07-13 18:13:04 +01:00
|
|
|
|
var di = new DirectoryInfo(_serverFixture.SiteSettings.GitRepository);
|
2019-01-05 13:28:17 +00:00
|
|
|
|
if (!di.Exists) di.Create();
|
2018-07-25 02:12:13 +02:00
|
|
|
|
|
2025-07-13 18:13:04 +01:00
|
|
|
|
var clone = new GitClone(_serverFixture.SiteSettings.GitRepository);
|
2018-07-25 02:12:13 +02:00
|
|
|
|
clone.Launch(firstProject);
|
2019-05-24 20:14:38 +01:00
|
|
|
|
gitRepo = di.FullName;
|
2018-07-15 06:47:41 +02:00
|
|
|
|
}
|
2019-05-24 20:14:38 +01:00
|
|
|
|
string gitRepo=null;
|
2025-07-13 18:13:04 +01:00
|
|
|
|
private IConfigurationRoot configurationRoot;
|
2018-07-15 06:47:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2025-07-13 18:13:04 +01:00
|
|
|
|
public void HaveConfigurationRoot()
|
2018-07-15 06:47:41 +02:00
|
|
|
|
{
|
|
|
|
|
|
var builder = new ConfigurationBuilder();
|
|
|
|
|
|
configurationRoot = builder.Build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-24 20:14:38 +01:00
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (gitRepo!=null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.Delete(Path.Combine(gitRepo,"yavsc"), true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-15 06:47:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|