Reformat / cleanup
This commit is contained in:
@@ -1,32 +1,27 @@
|
||||
using ZB.MOM.WW.CBDD.Bson;
|
||||
using ZB.MOM.WW.CBDD.Core.Collections;
|
||||
using ZB.MOM.WW.CBDD.Core.Storage;
|
||||
using ZB.MOM.WW.CBDD.Core.Transactions;
|
||||
using ZB.MOM.WW.CBDD.Shared;
|
||||
using ZB.MOM.WW.CBDD.Shared.TestDbContext_TestDbContext_Mappers;
|
||||
using Xunit;
|
||||
|
||||
namespace ZB.MOM.WW.CBDD.Tests;
|
||||
|
||||
public class DocumentCollectionDeleteTests : IDisposable
|
||||
{
|
||||
private readonly TestDbContext _dbContext;
|
||||
private readonly string _dbPath;
|
||||
private readonly string _walPath;
|
||||
private readonly Shared.TestDbContext _dbContext;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DocumentCollectionDeleteTests"/> class.
|
||||
/// Initializes a new instance of the <see cref="DocumentCollectionDeleteTests" /> class.
|
||||
/// </summary>
|
||||
public DocumentCollectionDeleteTests()
|
||||
{
|
||||
_dbPath = Path.Combine(Path.GetTempPath(), $"test_delete_{Guid.NewGuid()}.db");
|
||||
_walPath = Path.Combine(Path.GetTempPath(), $"test_delete_{Guid.NewGuid()}.wal");
|
||||
|
||||
_dbContext = new Shared.TestDbContext(_dbPath);
|
||||
_dbContext = new TestDbContext(_dbPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases test resources.
|
||||
/// Releases test resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -34,7 +29,7 @@ public class DocumentCollectionDeleteTests : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies delete removes both the document and its index entry.
|
||||
/// Verifies delete removes both the document and its index entry.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Delete_RemovesDocumentAndIndexEntry()
|
||||
@@ -47,7 +42,7 @@ public class DocumentCollectionDeleteTests : IDisposable
|
||||
_dbContext.Users.FindById(user.Id).ShouldNotBeNull();
|
||||
|
||||
// Delete
|
||||
var deleted = _dbContext.Users.Delete(user.Id);
|
||||
bool deleted = _dbContext.Users.Delete(user.Id);
|
||||
_dbContext.SaveChanges();
|
||||
|
||||
// Assert
|
||||
@@ -62,19 +57,19 @@ public class DocumentCollectionDeleteTests : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies delete returns false for a non-existent document.
|
||||
/// Verifies delete returns false for a non-existent document.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Delete_NonExistent_ReturnsFalse()
|
||||
{
|
||||
var id = ObjectId.NewObjectId();
|
||||
var deleted = _dbContext.Users.Delete(id);
|
||||
bool deleted = _dbContext.Users.Delete(id);
|
||||
_dbContext.SaveChanges();
|
||||
deleted.ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies deletes inside a transaction commit successfully.
|
||||
/// Verifies deletes inside a transaction commit successfully.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Delete_WithTransaction_CommitsSuccessfully()
|
||||
@@ -92,4 +87,4 @@ public class DocumentCollectionDeleteTests : IDisposable
|
||||
// Verify
|
||||
_dbContext.Users.FindById(user.Id).ShouldBeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user