How to check check Constrains in test ?
Todo: i need to insert some description :D When we need to check check, we need to use Sqlite provider
When use providers:
using System;
using System.Threading.Tasks;
using Bogus;
using Microsoft.EntityFrameworkCore;
using TrackingConsumerService.Data;
using TrackingConsumerService.Data.Models;
using Xunit;
namespace TrackingConsumerService.Test.Fixture
{
public class DbContextFixture : IDisposable
{
public MyDbContest DbContext { get; private set; }
public DbContextFixture()
{
var options = new DbContextOptionsBuilder<MyDbContest>()
.UseSqlite("Filename=:memory:")
.Options;
DbContext = new MyDbContest(options);
DbContext.Database.OpenConnection();
DbContext.Database.EnsureCreated();
}
public void Dispose()
{
DbContext?.Database?.CloseConnection();
DbContext?.Dispose();
}
}
[CollectionDefinition("DbContext")]
public class InMemoryDbContextFixtureCollection : ICollectionFixture<DbContextFixture>
{
// This class has no code, and is never created. Its purpose is simply
// to be the place to apply [CollectionDefinition] and all the
// ICollectionFixture<> interfaces.
}
}
todo: add test example