Reformat / cleanup
This commit is contained in:
@@ -1,43 +1,42 @@
|
||||
using ZB.MOM.WW.CBDD.Shared;
|
||||
|
||||
namespace ZB.MOM.WW.CBDD.Tests
|
||||
namespace ZB.MOM.WW.CBDD.Tests;
|
||||
|
||||
public class AutoInitTests : IDisposable
|
||||
{
|
||||
public class AutoInitTests : System.IDisposable
|
||||
private const string DbPath = "autoinit.db";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoInitTests" /> class.
|
||||
/// </summary>
|
||||
public AutoInitTests()
|
||||
{
|
||||
private const string DbPath = "autoinit.db";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoInitTests"/> class.
|
||||
/// </summary>
|
||||
public AutoInitTests()
|
||||
{
|
||||
if (File.Exists(DbPath)) File.Delete(DbPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases test resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (File.Exists(DbPath)) File.Delete(DbPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies generated collection initializers set up collections automatically.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Collections_Are_Initialized_By_Generator()
|
||||
{
|
||||
using var db = new Shared.TestDbContext(DbPath);
|
||||
|
||||
// Verify Collection is not null (initialized by generated method)
|
||||
db.AutoInitEntities.ShouldNotBeNull();
|
||||
|
||||
// Verify we can use it
|
||||
db.AutoInitEntities.Insert(new AutoInitEntity { Id = 1, Name = "Test" });
|
||||
var stored = db.AutoInitEntities.FindById(1);
|
||||
stored.ShouldNotBeNull();
|
||||
stored.Name.ShouldBe("Test");
|
||||
}
|
||||
if (File.Exists(DbPath)) File.Delete(DbPath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases test resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (File.Exists(DbPath)) File.Delete(DbPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies generated collection initializers set up collections automatically.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Collections_Are_Initialized_By_Generator()
|
||||
{
|
||||
using var db = new TestDbContext(DbPath);
|
||||
|
||||
// Verify Collection is not null (initialized by generated method)
|
||||
db.AutoInitEntities.ShouldNotBeNull();
|
||||
|
||||
// Verify we can use it
|
||||
db.AutoInitEntities.Insert(new AutoInitEntity { Id = 1, Name = "Test" });
|
||||
var stored = db.AutoInitEntities.FindById(1);
|
||||
stored.ShouldNotBeNull();
|
||||
stored.Name.ShouldBe("Test");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user