mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-06 08:46:39 +00:00
tests passed
This commit is contained in:
parent
bc400ae21a
commit
1bad110524
3 changed files with 1 additions and 79 deletions
|
|
@ -47,7 +47,7 @@ namespace TicketManager.Models
|
|||
{
|
||||
return Project.Assignments.Select(a => a.User).ToList();
|
||||
}
|
||||
public void GetLastUpdateTime() { throw new NotImplementedException("Not Implemented"); }
|
||||
public void GetLastUpdateTime() { throw new NotImplementedException("Not Implemented Yet."); }
|
||||
public void Close()
|
||||
{
|
||||
Status = Status.Done;
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TicketManager.Data;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace TicketManager._
|
||||
{
|
||||
public class ControllersTests
|
||||
{
|
||||
|
||||
public static void Wrapper(
|
||||
Func<DbContextOptions<AppDbContext>, Task> Test,
|
||||
Action<DbContextOptions<AppDbContext>> SeedDb)
|
||||
{
|
||||
// Create inMemory Test Database
|
||||
var connection = new SqliteConnection("DataSource=:memory:");
|
||||
connection.Open();
|
||||
|
||||
try
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseSqlite(connection)
|
||||
.Options;
|
||||
|
||||
// creates DB schema
|
||||
using (var context = new AppDbContext(options))
|
||||
{
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
// Seed DB usng one context instance
|
||||
SeedDb(options);
|
||||
|
||||
// use another context instance to run the test
|
||||
Test(options);
|
||||
}
|
||||
finally
|
||||
{
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
using System;
|
||||
using TicketManager.Data;
|
||||
using TicketManager.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace TicketManager._
|
||||
{
|
||||
public class SeedDb
|
||||
{
|
||||
public static void Projects(DbContextOptions<AppDbContext> options)
|
||||
// Seed DB usng one context instance
|
||||
{
|
||||
using (var context = new AppDbContext(options))
|
||||
{
|
||||
context.Projects.AddRange(
|
||||
new Project()
|
||||
{
|
||||
Id = 1,
|
||||
Title = "Secret Project",
|
||||
Description = "Shht Don't Ask don't tell",
|
||||
PlannedEnding = new DateTime(2021, 7, 21)
|
||||
},
|
||||
new Project()
|
||||
{
|
||||
Id = 2,
|
||||
Title = "Public Project",
|
||||
Description = "It's quite obvious, isn't it?!",
|
||||
PlannedEnding = new DateTime(2036, 6, 16)
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue